On Jan 18, 12:13 am, dhs227 <[email protected]> wrote: > DB = > Sequel.ado(:conn_string=>'Provider=SQLNCLI10;Server=localhost;Database=db1;User > ID=da;Password=123456') > dataset = DB['select count(*) , \'1234\' from Mytable'] > dataset.each{|row| p row} > print p > ########################### > Run above code to see output, > Expect "{:"count(*)"=>58, :"1234"=>"1234"}" > Actually "{:untitled=>"1234"}"
You didn't provide aliases for your columns, so the column names in the result set are up to the database. In your case, the database doesn't provide an column name for either column (most databases do), so Sequel uses "untitled". Since both columns have the same name, and Sequel uses a hash to store the results, one of the columns overwrites the other one in the result hash. The solution is to give aliases for your columns: dataset = DB['select count(*) AS count, \'1234\' as num from Mytable'] Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
