In Sequel ORM for Ruby, the Dataset class has an all method that creates an array of row hashes: each row is a hash with column names as keys.
For example, given table T:
abc -------------- 0 22 "Abe" 1 35 "Betty" 2 58 "Chris"
then
ds = DB['select a, b, c from T'] ah = ds.all # Array of row Hashes
must produce:
[{"a":0,"b":22,"c":"Abe"},{"a":1,"b":35,"c":"Betty"},{"a":2,"b":58,"c":"Chris"}]
Is there a way that you can create an array of string arrays in Sequel, where each row is an array of only the values โโin each row in the order specified in the request? How does select_rows work in ActiveRecord? Something like that:
aa = ds.rows
which will produce:
[[0,22,"Abe"],[1,35,"Betty"],[2,58,"Chris"]]
Note: expression:
aa = ds.map { |h| h.values }
creates an array of arrays, but the order of the values โโin the strings is NOT guaranteed to match the order specified in the original query. In this example, aa might look like this:
[["Abe",0,22],["Betty",1,35],["Chris",2,58]]