goqu icon indicating copy to clipboard operation
goqu copied to clipboard

feat: allow conflict targets in ON CONFLICT DO NOTHING

Open pedrohavay opened this issue 9 months ago • 0 comments

I have added the ability to specify conflict target columns for the ON CONFLICT clause, which is necessary for PostgreSQL.

Now it is possible to handle conflicts by specifying columns for conflict handling:

sql, _, _ := goqu.Insert("test").
	Rows(goqu.Record{"a": "a", "b"}).
	OnConflict(goqu.DoNothing().SetCols(exp.NewColumnListExpression("a", "b"))).
	ToSQL()
fmt.Println(sql)

Then you will get:

INSERT INTO "test" ("a", "b") VALUES ('a', 'b') ON CONFLICT ("a", "b") DO NOTHING

pedrohavay avatar May 20 '24 23:05 pedrohavay