Repository navigation
feat(analysis): accept targetless, named, and predicated ON CONFLICT - #73
Merged
omer-cengel merged 1 commit intoOct 11, 2026
Conversation
An INSERT may now use ON CONFLICT DO NOTHING without a target, ON CONFLICT ON CONSTRAINT name with either action, a predicate on a column-name conflict target, and DO UPDATE ... WHERE, on :exec and returning inserts alike. The constraint name is resolved by PostgreSQL. Placeholders in a target predicate are typed by the WHERE rules over the inserted table under its exposed name; those in DO UPDATE ... WHERE over that table and EXCLUDED, so an unqualified column of both is ambiguous. All conflict placeholders bind in textual order. DO UPDATE without a target is rejected naming ON CONFLICT (id) and ON CONSTRAINT as the fix.
omer-cengel
deleted the
feature/targetless-named-and-predicated-conflict-clauses
branch
October 11, 2026 13:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upserts can now use the conflict-clause forms that need no new type inference:
ON CONFLICT DO NOTHINGwithout a target,ON CONFLICT ON CONSTRAINT name, a predicate on a column-name conflict target, andDO UPDATE ... WHERE. These were previously rejected even though everything they bind can be typed by the existingWHERErules.Changes
ON CONFLICT DO NOTHINGwithout a conflict target on:execand returning inserts.ON CONFLICT ON CONSTRAINT namewithDO NOTHINGorDO UPDATE; PostgreSQL resolves the constraint name.WHERErules against the inserted table under its exposed name (its alias when present).DO UPDATE ... WHERE, typing its placeholders against both the inserted table andEXCLUDED; an unqualified column present in both is reported as ambiguous, as PostgreSQL does.DO UPDATEwithout a conflict target with a message namingON CONFLICT (id)andON CONFLICT ON CONSTRAINT nameas the fix.DO UPDATE ... WHEREthat updates once and then skips.Scope and non-goals
WHERE.WHERErules cannot type keep the existing rejection; no new diagnostic is added.