Fix zero-datetime in statement result raises ArgumentError#1054
Fix zero-datetime in statement result raises ArgumentError#1054gentlawk wants to merge 3 commits into
Conversation
| if (seconds == 0) { | ||
| val = Qnil; | ||
| } else { | ||
| if (seconds < MYSQL2_MIN_TIME || seconds > MYSQL2_MAX_TIME) { // use DateTime instead |
There was a problem hiding this comment.
It would be equivalent to move this up as } else if (seconds...) {, no need to indent the entire if block.
|
I didn't get this one into the 0.5.3 release, but I want to plan for whether to include it in the next release or not. If you'd be so kind as to make the requested change to the if block? |
|
Thanks for your advice! |
d4740d3 to
946532d
Compare
|
Hmm... you are exactly. |
|
I am confused why MySQL doesn't return NULL as the value type in this case, and is instead giving back an all-zeroes date value. It seems like the fix is papering over some quirk here. That said, it does appear that there's "no such thing" as an all-zeroes DATETIME, so mapping that to NULL appears consistent with MySQL's own behavior. Maybe the command-line client is actually doing this same paper-over? Here's my local session output: |
|
Thanks for taking the review feedback, the changes look good. I just want to make sure I understand this under the hood before landing the PR. |
|
Possibly, would your MySQL be running with 'NO_ZERO_DATE' mode? |

A zero-datetime value ('0000-00-00 00:00:00') is returned nil by Client#query,
but raises ArgumentError by Statement#execute.
I fixed Statement#execute to return nil correctly for zero-datetime.