I did the horrible hack of changing the mysql.rb to be this:
# Convert the type of v using the method in MYSQL_TYPES[type].
def convert_type(v, type)
if v
if type == 1 && Sequel.convert_tinyint_to_bool
# We special case tinyint here to avoid adding
# a method to an ancestor of Fixnum
v.to_i == 0 ? false : true
else
if v == '0000-00-00 00:00:00' or v == '0000-00-00' then
nil
else
(t = MYSQL_TYPES[type]) ? v.send(t) : v
end
end
else
nil
end
end
But of course, would like something better that doesn't require
hacking the gem!
Eric
On Mar 16, 2009, at 5:38 PM, Eric Pugh wrote:
>
> I am working with a legacy MySQL database where NULL dates are
> displayed as 0000-00-00 00:00:00. This causes a problem in conversion
> (reasonably enough!):
>
> /opt/local/lib/ruby/gems/1.8/gems/sequel-2.11.0/lib/sequel_core/
> core_ext.rb:198:in `to_sequel_time': Invalid Time value '0000-00-00
> 00:00:00' (argument out of range) (Sequel::Error::InvalidValue)
> from /opt/local/lib/ruby/gems/1.8/gems/sequel-2.11.0/lib/
> sequel_core/adapters/mysql.rb:334:in `send'
> from /opt/local/lib/ruby/gems/1.8/gems/sequel-2.11.0/lib/
> sequel_core/adapters/mysql.rb:334:in `convert_type'
>
> Is there a way to tell it to swap to NULL instead? I know there is a
> JDBC Driver setting that does this, but don't quite see how to do in
> with Sequel...
>
> Thanks!
>
> Eric
>
> >
-----------------------------------------------------
Eric Pugh | Principal | OpenSource Connections, LLC | 434.466.1467 |
http://www.opensourceconnections.com
Free/Busy: http://tinyurl.com/eric-cal
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
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
-~----------~----~----~----~------~----~------~--~---