Skip to content

Set a nil date to NULL rather than 0000-00-00 #346

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

Closed
wants to merge 6 commits into from
7 changes: 7 additions & 0 deletions packets.go
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,13 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
}

case time.Time:
if stmt.mc.strict && v.IsZero() {
nullMask[i/8] |= 1 << (uint(i) & 7)
paramTypes[i+i] = fieldTypeNULL
paramTypes[i+i+1] = 0x00
continue
}

paramTypes[i+i] = fieldTypeString
paramTypes[i+i+1] = 0x00

Expand Down