Skip to content

Commit

Permalink
Add test for using BulkSQL with a SELECT
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Aug 28, 2023
1 parent bf60e41 commit c616cdf
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dbutil/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ func TestBulkSQL(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, `INSERT INTO foo (id, name) VALUES($1, $2),($3, $4),($5, $6)`, query)
assert.Equal(t, []any{1, "Bob", 2, "Cathy", 3, "George"}, args)

// try a select
sql = `SELECT * FROM foo WHERE (id, name) IN (VALUES(:id, :name))`

query, args, err = dbutil.BulkSQL(db, sql, []any{contact{ID: 1, Name: "Bob"}, contact{ID: 2, Name: "Cathy"}})
assert.NoError(t, err)
assert.Equal(t, `SELECT * FROM foo WHERE (id, name) IN (VALUES($1, $2),($3, $4))`, query)
assert.Equal(t, []any{1, "Bob", 2, "Cathy"}, args)
}

func TestBulkQuery(t *testing.T) {
Expand Down

0 comments on commit c616cdf

Please sign in to comment.