Skip to content

Commit

Permalink
test: add test case for empty string + nullzero
Browse files Browse the repository at this point in the history
  • Loading branch information
bevzzz committed Jan 7, 2024
1 parent 3696bd4 commit d45e285
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions internal/dbtest/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,12 @@ func TestQuery(t *testing.T) {
// "nullzero" marshals zero values as DEFAULT or NULL (if DEFAULT placeholder is not supported)
// DB drivers which support DEFAULT placeholder resolve it to NULL for columns that do not have a DEFAULT value.
type Model struct {
Int int64 `bun:",nullzero"`
Uint uint64 `bun:",nullzero"`
Str string `bun:",nullzero"`
Time time.Time `bun:",nullzero"`
Bool bool `bun:",nullzero"`
// EmptyStr string `bun:",nullzero"` -- same as Str
Int int64 `bun:",nullzero"`
Uint uint64 `bun:",nullzero"`
Str string `bun:",nullzero"`
Time time.Time `bun:",nullzero"`
Bool bool `bun:",nullzero"`
EmptyStr string `bun:",nullzero"` // same as Str
}
return db.NewInsert().Model(new(Model))
},
Expand Down
2 changes: 1 addition & 1 deletion internal/dbtest/testdata/snapshots/TestQuery-mariadb-51
Original file line number Diff line number Diff line change
@@ -1 +1 @@
INSERT INTO `models` (`int`, `uint`, `str`, `time`, `bool`) VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT) RETURNING `int`, `uint`, `str`, `time`, `bool`
INSERT INTO `models` (`int`, `uint`, `str`, `time`, `bool`, `empty_str`) VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT) RETURNING `int`, `uint`, `str`, `time`, `bool`, `empty_str`
2 changes: 1 addition & 1 deletion internal/dbtest/testdata/snapshots/TestQuery-mssql2019-51
Original file line number Diff line number Diff line change
@@ -1 +1 @@
INSERT INTO "models" ("int", "uint", "str", "time", "bool") VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT)
INSERT INTO "models" ("int", "uint", "str", "time", "bool", "empty_str") VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT)
2 changes: 1 addition & 1 deletion internal/dbtest/testdata/snapshots/TestQuery-mysql5-51
Original file line number Diff line number Diff line change
@@ -1 +1 @@
INSERT INTO `models` (`int`, `uint`, `str`, `time`, `bool`) VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT)
INSERT INTO `models` (`int`, `uint`, `str`, `time`, `bool`, `empty_str`) VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT)
2 changes: 1 addition & 1 deletion internal/dbtest/testdata/snapshots/TestQuery-mysql8-51
Original file line number Diff line number Diff line change
@@ -1 +1 @@
INSERT INTO `models` (`int`, `uint`, `str`, `time`, `bool`) VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT)
INSERT INTO `models` (`int`, `uint`, `str`, `time`, `bool`, `empty_str`) VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT)
2 changes: 1 addition & 1 deletion internal/dbtest/testdata/snapshots/TestQuery-pg-51
Original file line number Diff line number Diff line change
@@ -1 +1 @@
INSERT INTO "models" ("int", "uint", "str", "time", "bool") VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT) RETURNING "int", "uint", "str", "time", "bool"
INSERT INTO "models" ("int", "uint", "str", "time", "bool", "empty_str") VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT) RETURNING "int", "uint", "str", "time", "bool", "empty_str"
2 changes: 1 addition & 1 deletion internal/dbtest/testdata/snapshots/TestQuery-pgx-51
Original file line number Diff line number Diff line change
@@ -1 +1 @@
INSERT INTO "models" ("int", "uint", "str", "time", "bool") VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT) RETURNING "int", "uint", "str", "time", "bool"
INSERT INTO "models" ("int", "uint", "str", "time", "bool", "empty_str") VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT) RETURNING "int", "uint", "str", "time", "bool", "empty_str"
2 changes: 1 addition & 1 deletion internal/dbtest/testdata/snapshots/TestQuery-sqlite-51
Original file line number Diff line number Diff line change
@@ -1 +1 @@
INSERT INTO "models" ("int", "uint", "str", "time", "bool") VALUES (NULL, NULL, NULL, NULL, NULL) RETURNING "int", "uint", "str", "time", "bool"
INSERT INTO "models" ("int", "uint", "str", "time", "bool", "empty_str") VALUES (NULL, NULL, NULL, NULL, NULL, NULL) RETURNING "int", "uint", "str", "time", "bool", "empty_str"

0 comments on commit d45e285

Please sign in to comment.