ActiveRecord:在多语句查询中忽略第一个查询的结果

ActiveRecord: Result of first query ignored in multi statement query

我是 运行 一个使用 ActiveRecord 和 Mysql(mysql2 通过 makara 适配器)的多语句查询,我试图将结果存储在一个数组中。但是我没有得到第一个查询的结果。下面是代码片段。请让我知道我在这里遗漏了什么。

ActiveRecord::Base.transaction do
    client = ActiveRecord::Base.connection.raw_connection
    test_sql = "select id, email from members where id = 1; select id, pref member_prefs where member_id = 1;"
    client.query(test_sql)
    res = []
    while client.next_result
       res << client.store_result
    end

    puts "res size: #{res.size}"
    res.each do |row|
       puts "row: #{row.to_json}"
    end
end

Output:
res size: 1
row: [[1, 3]]

If I add "select 1; " before the query, it gives me two results(though the output of the 1st query is missing)
Output:
res size: 2
row: [[1, abc@def.com]]
row: [[1, 3]]


提前致谢

我找到了。可能是一个愚蠢的错误。放在这里供参考。

第一个查询的结果作为 client.query(test_sql) 语句的响应返回。