Skip to content

feat: allow conflict targets in ON CONFLICT DO NOTHING#422

Open
pedrohavay wants to merge 1 commit into
doug-martin:masterfrom
pedrohavay:onconflict
Open

feat: allow conflict targets in ON CONFLICT DO NOTHING#422
pedrohavay wants to merge 1 commit into
doug-martin:masterfrom
pedrohavay:onconflict

Conversation

@pedrohavay

@pedrohavay pedrohavay commented May 20, 2024

Copy link
Copy Markdown

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant