Add support for additional array types.

This commit is contained in:
go-jet 2025-10-16 15:09:07 +02:00
parent 45d4ced9b0
commit 4ee047a675
47 changed files with 1994 additions and 4277 deletions

View file

@ -175,30 +175,27 @@ RETURNING table1.col1 AS "table1.col1",
}
func TestInsert_ON_CONFLICT_ON_CONSTRAINT(t *testing.T) {
stmt := table1.INSERT(table1Col1, table1ColBool, table1ColStringArray).
VALUES("one", "two", "three").
VALUES("1", "2", "3").
ON_CONFLICT().ON_CONSTRAINT("idk_primary_key").DO_UPDATE(
SET(table1ColBool.SET(Bool(false)),
table2ColInt.SET(Int(1)),
table1ColStringArray.SET(StringArray([]string{"one"})),
ColumnList{table1Col1, table1ColBool, table1ColStringArray}.SET(jet.ROW(Int(2), String("two"), StringArray([]string{"two"}))),
).WHERE(table1Col1.GT(Int(2))),
).
RETURNING(table1Col1, table1ColBool, table1ColStringArray)
stmt := table1.INSERT(table1Col1, table1ColBool).
VALUES("one", "two").
VALUES("1", "2").
ON_CONFLICT().ON_CONSTRAINT("idk_primary_key").
DO_UPDATE(
SET(table1ColBool.SET(Bool(false)),
table2ColInt.SET(Int(1)),
ColumnList{table1Col1, table1ColBool}.SET(ROW(Int(2), String("two"))),
).WHERE(table1Col1.GT(Int(2)))).
RETURNING(table1Col1, table1ColBool)
assertDebugStatementSql(t, stmt, `
INSERT INTO db.table1 (col1, col_bool, col_string_array)
VALUES ('one', 'two', 'three'),
('1', '2', '3')
INSERT INTO db.table1 (col1, col_bool)
VALUES ('one', 'two'),
('1', '2')
ON CONFLICT ON CONSTRAINT idk_primary_key DO UPDATE
SET col_bool = FALSE::boolean,
col_int = 1,
col_string_array = '{"one"}',
(col1, col_bool, col_string_array) = ROW(2, 'two'::text, '{"two"}')
(col1, col_bool) = ROW(2, 'two'::text)
WHERE table1.col1 > 2
RETURNING table1.col1 AS "table1.col1",
table1.col_bool AS "table1.col_bool",
table1.col_string_array AS "table1.col_string_array";
table1.col_bool AS "table1.col_bool";
`)
}