Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ON CONFLICT DO NOTHING without a conflict target is valid SQL #335

Conversation

BillBuilt
Copy link
Contributor

ON CONFLICT DO NOTHING without a conflict target is valid SQL according to Postgres.

https://www.postgresql.org/docs/15/sql-insert.html#SQL-ON-CONFLICT

@go-jet
Copy link
Owner

go-jet commented Mar 20, 2024

Hi @BillBuilt, good catch.

@@ -44,7 +44,7 @@ func (o *onConflictClause) DO_UPDATE(action conflictAction) InsertStatement {
}

func (o *onConflictClause) Serialize(statementType jet.StatementType, out *jet.SQLBuilder, options ...jet.SerializeOption) {
if len(o.indexExpressions) == 0 && o.constraint == "" {
if len(o.indexExpressions) == 0 && o.constraint == "" && o.do != jet.Keyword("DO NOTHING") {
Copy link
Owner

@go-jet go-jet Mar 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not o.do == nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea That's probably better.

@go-jet go-jet changed the base branch from master to develop March 24, 2024 11:41
@go-jet go-jet merged commit 60d8f15 into go-jet:develop Mar 24, 2024
3 checks passed
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.

2 participants