Skip to content

Commit

Permalink
fix: allow zero time
Browse files Browse the repository at this point in the history
  • Loading branch information
inoth committed Dec 25, 2024
1 parent f0ca5b7 commit d5006de
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
3 changes: 1 addition & 2 deletions mysql/resultset_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package mysql
import (
"bytes"
"encoding/binary"
"fmt"
"math"
"strconv"
"time"
Expand Down Expand Up @@ -56,7 +55,7 @@ func toBinaryDateTime(t time.Time) ([]byte, error) {
var buf bytes.Buffer

if t.IsZero() {
return nil, fmt.Errorf("zero time")
return nil, nil
}

year, month, day := t.Year(), t.Month(), t.Day()
Expand Down
1 change: 0 additions & 1 deletion mysql/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func TestToBinaryDateTime(t *testing.T) {
Name: "Zero time",
Data: time.Time{},
Expect: nil,
Error: true,
},
{
Name: "Date with nanoseconds",
Expand Down

0 comments on commit d5006de

Please sign in to comment.