I have a query in my Ruby file:
@mastertest = connection.execute("select code_ver, date from mastertest")
It treats @mastertest like a 2-D array because, when I print the rows, I get:
@mastertest.each do |row|
puts row[0] : row[1]
end
This prints all code_ver and date from each row.
I am not able to perform any other operations on it. I cannot sort the array nor can I perform a deep copy of the array. I’m guessing it is some MySQL2 type which Ruby considers. How do I convert this to a normal 2-D array?
The class of @mastertest is
Mysql2::Result; it provides onlyeachandfieldsmethodsHere’s an example for one way to convert the results into a 2-D array: