I was under the assumption that any decent database adapter would convert  
the column into the relevant native language types for you (ie. integer  
column => ruby integer).
	Is this not the case ?

	I had problems in Python because the postgresql adapter only managed the  
default types (int, float, string, bool) and not the fancy types (arrays,  
trees, geometric coordinates...) but in your case it might be worthy to  
use an object to database mapper to automate the process ?


On Mon, 18 Apr 2005 13:28:32 +0200, <pmak / aaanime.net> wrote:

> I'm programming an application that saves its data in a MySQL
> database. I frequently run into headaches where I get errors like:
>
>     undefined method `-' for "9000.00":String (NameError)
>
> because I typed
>
>     source['salary'] -= encumbered['salary']
>
> where source[] and encumbered[] were instantiated from
> MysqlResult#fetch_hash, and are thus strings instead of integers or
> floats.
>
> I write this sort of thing all the time in Perl and don't have trouble
> because of its automatic type conversion. What would be the best way
> to do this in Ruby? Right now I'm writing:
>
>     source['salary'] = source['salary'].to_f -
> encumbered['salary'].to_f
>
> everywhere and it feels quite tedious.
>