Skip to content

Commit

Permalink
add ptr time.Time encode test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
future-taga committed Jun 28, 2022
1 parent de42c42 commit 17371e9
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1126,11 +1126,6 @@ func TestEval_NestStructTyp(t *testing.T) {
EmbedNullString sql.NullString `db:"embed_null_string"`
EmbedTime time.Time `db:"embed_time"`
EmbedPtrTime *time.Time `db:"embed_ptr_time"`

Skip string
Nest struct {
ID string
}
}

type SQLTypInfo struct {
Expand All @@ -1142,6 +1137,7 @@ func TestEval_NestStructTyp(t *testing.T) {
NullString sql.NullString `db:"null_string"`
NullTime sql.NullTime `db:"null_time"`
Time time.Time `db:"time"`
PtrTime *time.Time `db:"ptr_time"`

Embed Embed
}
Expand Down Expand Up @@ -1228,6 +1224,18 @@ func TestEval_NestStructTyp(t *testing.T) {
wantQuery: `SELECT * FROM person WHERE value = ?/*time*/`,
wantParams: []interface{}{time.Date(2022, 7, 1, 12, 30, 30, 0, time.UTC)},
},
{
name: "bind ptr time.Time",
input: `SELECT * FROM person WHERE value = /*ptr_time*/'2022-01-01 10:00:00'`,
inputParams: SQLTypInfo{
PtrTime: func() *time.Time {
d := time.Date(2022, 7, 1, 12, 30, 30, 0, time.UTC)
return &d
}(),
},
wantQuery: `SELECT * FROM person WHERE value = ?/*ptr_time*/`,
wantParams: []interface{}{time.Date(2022, 7, 1, 12, 30, 30, 0, time.UTC)},
},
{
name: "bind initial",
input: `SELECT * FROM person WHERE value = /*null_string*/'hoge'`,
Expand Down

0 comments on commit 17371e9

Please sign in to comment.