On Thursday, August 16, 2012 9:26:14 AM UTC-7, g_f wrote: > > On Wednesday, August 15, 2012 4:55:37 PM UTC-7, Jeremy Evans wrote: >> >> >> An unsigned->signed conversion shouldn't produce problems except in the >> case of overflow. If the problem is an overflow issue, you can use >> .cast_numeric(:unsigned) to cast to unsigned instead of signed. >> >> You are getting entries such as :"CAST(`max_subnet_ip_int` AS SIGNED)"in >> your result hash because you aren't aliasing the casts and those are the >> default column names used by MySQL. You probably want: : >> ip_int.cast_numeric.as(:ip_int) >> >> Thanks, >> Jeremy >> > > Looking through the docs further, I found the DB.set_column_type method, > which seems to be a more straightforward way to get where I want to be: > > # cast the IP integer columns to integers > [:ip_int, :min_subnet_ip_int, :max_subnet_ip_int].each do |f| > DB.set_column_type :ips, f, :integer > end >
I'm not sure that does what you want. That doesn't set up a cast (which is a per query operation), it converts the column's type from one type to another (which affects all subsequent queries). > It would be nice if it understood :unsigned or :unsigned_integer, but > :integer seems to do the trick for now. > You should be able to use any database type mysql accepts. I think 'integer unsigned' works. Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/sequel-talk/-/C7IjIGDfjBUJ. 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.
