That is because you are not using the rails way of working. If you pass custom sql requests to the database, the return type will always be a string and you need to convert the value yourself (.to_i).
But in your case I have no clue why you are not using ActiveRecord like you should:
That is because you are not using the rails way of working. If you
pass custom sql requests to the database, the return type will always
be a string and you need to convert the value yourself (.to_i).
It's rather curiously, because Oracle driver for Ruby On Rails solves my
problem successfully (I use Rails + Oracle in my work project) - there
isn't any problem with data type definition. It's very pity, that MySQL
adapter works so simple...
All I was pointing out was that you are using raw sql queries while using such a huge library as ActiveRecord which does it all for you in a more Ruby-ish way. And the added bonus is that you don’t have to worry about the database backend because of the database abstraction you get for free.
Raw SQL queries do have their place though (very complex queries or occasional optimizations), but if you can avoid them, you should.