I'm looking for an explanation of the result of the following query with Active Record:
date_range = (Date.today - 7)..(Time.now.to_datetime)
r = Report.find(:all, :conditions => {:created_at => date_range},
:group => 'date(created_at)',
:select => 'date(created_at) as day, count(id) as counter')
Basically I'm just counting the results in a table "reports," but I got different types of values for the named field "counter", array of double quote strings vs array of only numbers.
MySQL
If using MySQL,
r.map(&:counter)
returns:
=> ["3", "3", "5", "4", "4"]
SQLite
If using SQLite,
r.map(&:counter)
returns:
=> [3, 3, 5, 4, 4]
Is it correct that MySQL returns the numbers with quotes (Strings) and SQLite numbers? I expected that both return just integers. Or am I missing some configuration with on MySQL side?
Edit:
Just in case, both DBs where created using normal migrations, so all fields are equivalent types.