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 It would be nice if it understood :unsigned or :unsigned_integer, but :integer seems to do the trick for now. -- 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/-/QoGHRZosG70J. 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.
