File size: 661 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
package swoinfo
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestTable_InsertJSONRowsQuery(t *testing.T) {
tbl := Table{
name: "test",
cols: []column{
{ColColumnName: "id"},
{ColColumnName: "foo"},
{ColColumnName: "bar"},
},
}
query := tbl.InsertJSONRowsQuery(false)
assert.Equal(t, `insert into "test" select * from json_populate_recordset(null::"test", $1)`, query)
query = tbl.InsertJSONRowsQuery(true)
assert.Equal(t, `insert into "test" select * from json_populate_recordset(null::"test", $1) on conflict (id) do update set "foo" = excluded."foo", "bar" = excluded."bar" where "test".id = excluded.id`, query)
}
|