Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Driver does not convert "0000-00-00 00:00:00" correctly #4

Open
bsanders1979 opened this issue Oct 19, 2011 · 2 comments
Open

Driver does not convert "0000-00-00 00:00:00" correctly #4

bsanders1979 opened this issue Oct 19, 2011 · 2 comments
Assignees

Comments

@bsanders1979
Copy link

invalid date
e:/Ruby192/lib/ruby/1.9.1/date.rb:1691:in new_by_frags' e:/Ruby192/lib/ruby/1.9.1/date.rb:1736:inparse'
e:/Ruby192/lib/ruby/gems/1.9.1/gems/rdbi-driver-mysql-0.9.2/lib/rdbi/driver/mysql.rb:444:in block i n manipulate_type_maps' e:/Ruby192/lib/ruby/gems/1.9.1/gems/typelib-0.1.0/lib/typelib.rb:57:incall'
e:/Ruby192/lib/ruby/gems/1.9.1/gems/typelib-0.1.0/lib/typelib.rb:57:in convert' e:/Ruby192/lib/ruby/gems/1.9.1/gems/typelib-0.1.0/lib/typelib.rb:15:inexecute_filterlist'
e:/Ruby192/lib/ruby/gems/1.9.1/gems/rdbi-0.9.1/lib/rdbi/types.rb:163:in convert' e:/Ruby192/lib/ruby/gems/1.9.1/gems/rdbi-0.9.1/lib/rdbi/result.rb:382:inblock in convert_row'
e:/Ruby192/lib/ruby/gems/1.9.1/gems/rdbi-0.9.1/lib/rdbi/result.rb:381:in each' e:/Ruby192/lib/ruby/gems/1.9.1/gems/rdbi-0.9.1/lib/rdbi/result.rb:381:ineach_with_index'
e:/Ruby192/lib/ruby/gems/1.9.1/gems/rdbi-0.9.1/lib/rdbi/result.rb:381:in convert_row' e:/Ruby192/lib/ruby/gems/1.9.1/gems/rdbi-0.9.1/lib/rdbi/result.rb:353:inblock in fetch'
e:/Ruby192/lib/ruby/gems/1.9.1/gems/rdbi-0.9.1/lib/rdbi/result.rb:352:in each' e:/Ruby192/lib/ruby/gems/1.9.1/gems/rdbi-0.9.1/lib/rdbi/result.rb:352:infetch'
e:/Ruby192/lib/ruby/gems/1.9.1/gems/rdbi-0.9.1/lib/rdbi/result.rb:452:in fetch' e:/Ruby192/lib/ruby/gems/1.9.1/gems/rdbi-0.9.1/lib/rdbi/result.rb:232:infetch'

Create a table with a field of type "datetime", create a record with value of "0000-00-00 00:00:00" in that field, then execute.fetch(:all, :Struct) to reproduce.

ODBC driver returns nil which seems semantically correct. But, given that MySQL accepts such a value, seems like this might be debatable.

Perhaps wrapping rdbi-driver-mysql-0.9.2/lib/rdbi/driver/mysql.rb:444 in a begin/rescue block and setting the value to nil in the event of an exception would work?

@ghost ghost assigned pilcrow Oct 25, 2011
@pilcrow
Copy link
Member

pilcrow commented Oct 25, 2011

nil strikes me as the only acceptable return value unless we monkey with DateTime objects to encapsulate this special case. Hmm

@bsanders1979
Copy link
Author

I vote nil. I've fixed it on my end for the time being by placing the begin/rescue inside the closure/block. I found this issue because I'm developing a record archiving "engine" and my only concern at this point is that for the records which contain this value, they will not be truly equal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants