@@ -8,10 +8,11 @@ import (
8
8
)
9
9
10
10
type insertModel struct {
11
- IntField int64 `db:"int_field"`
12
- OtherValue string
13
- SkipInsert bool `goqux:"skip_insert"`
14
- DbTag string `db:"another_col_name"`
11
+ IntField int64 `db:"int_field"`
12
+ OtherValue string
13
+ SkipInsert bool `goqux:"skip_insert"`
14
+ DbTag string `db:"another_col_name"`
15
+ DbTagOmitEmpty string `db:"another_col_name_omit,omitempty"`
15
16
}
16
17
17
18
func TestBuildInsert (t * testing.T ) {
@@ -25,6 +26,13 @@ func TestBuildInsert(t *testing.T) {
25
26
}{
26
27
{
27
28
name : "simple_insert" ,
29
+ values : []any {insertModel {IntField : 5 , DbTagOmitEmpty : "test" }},
30
+ expectedQuery : `INSERT INTO "insert_models" ("another_col_name", "another_col_name_omit", "int_field", "other_value") VALUES ($1, $2, $3, $4)` ,
31
+ expectedArgs : []interface {}{"" , "test" , int64 (5 ), "" },
32
+ expectedError : nil ,
33
+ },
34
+ {
35
+ name : "simple_insert_ompitempty" ,
28
36
values : []any {insertModel {IntField : 5 }},
29
37
expectedQuery : `INSERT INTO "insert_models" ("another_col_name", "int_field", "other_value") VALUES ($1, $2, $3)` ,
30
38
expectedArgs : []interface {}{"" , int64 (5 ), "" },
0 commit comments