Skip to content

Commit

Permalink
fix: append slice values
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed Feb 17, 2022
1 parent 8333021 commit 4a65129
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
9 changes: 9 additions & 0 deletions internal/dbtest/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,15 @@ func TestQuery(t *testing.T) {
}
return db.NewInsert().Model(new(Model))
},
func(db *bun.DB) schema.QueryAppender {
models := []Model{
{42, "hello"},
{43, "foo"},
}
return db.NewInsert().
Model(&models).
Value("extra", "?", "custom")
},
}

timeRE := regexp.MustCompile(`'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+(\+\d{2}:\d{2})?'`)
Expand Down
1 change: 1 addition & 0 deletions internal/dbtest/testdata/snapshots/TestQuery-mariadb-107
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO `models` (`id`, `str`, `extra`) VALUES (42, 'hello', 'custom'), (43, 'foo', 'custom', 'custom')
1 change: 1 addition & 0 deletions internal/dbtest/testdata/snapshots/TestQuery-mysql5-107
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO `models` (`id`, `str`, `extra`) VALUES (42, 'hello', 'custom'), (43, 'foo', 'custom', 'custom')
1 change: 1 addition & 0 deletions internal/dbtest/testdata/snapshots/TestQuery-mysql8-107
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO `models` (`id`, `str`, `extra`) VALUES (42, 'hello', 'custom'), (43, 'foo', 'custom', 'custom')
1 change: 1 addition & 0 deletions internal/dbtest/testdata/snapshots/TestQuery-pg-107
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO "models" ("id", "str", "extra") VALUES (42, 'hello', 'custom'), (43, 'foo', 'custom', 'custom')
1 change: 1 addition & 0 deletions internal/dbtest/testdata/snapshots/TestQuery-pgx-107
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO "models" ("id", "str", "extra") VALUES (42, 'hello', 'custom'), (43, 'foo', 'custom', 'custom')
1 change: 1 addition & 0 deletions internal/dbtest/testdata/snapshots/TestQuery-sqlite-107
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO "models" ("id", "str", "extra") VALUES (42, 'hello', 'custom'), (43, 'foo', 'custom', 'custom')
11 changes: 0 additions & 11 deletions query_insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,17 +353,6 @@ func (q *InsertQuery) appendSliceValues(
}
}

for i, v := range q.extraValues {
if i > 0 || len(fields) > 0 {
b = append(b, ", "...)
}

b, err = v.value.AppendQuery(fmter, b)
if err != nil {
return nil, err
}
}

return b, nil
}

Expand Down

0 comments on commit 4a65129

Please sign in to comment.