Repository navigation
Support MERGE statement in PostgreSQL - #993
Open
emirmrkaljevic wants to merge 1 commit into
Open
emirmrkaljevic wants to merge 1 commit into
emirmrkaljevic wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Closes #986
PostgreSQL has had
MERGEsince version 15, but thepostgresqldialect didn't know about it, soMERGE INTO,WHEN [NOT] MATCHEDand the bareINSERTinside a merge action weren't treated as clauses and kept their original case.Changes:
MERGE INTO,WHEN [NOT] MATCHED [BY SOURCE | BY TARGET] [THEN]andUPDATE SETto the PostgreSQL reserved clauses (BY SOURCE/BY TARGETare PostgreSQL 17 syntax).INSERT INTOtoINSERT [INTO], since a merge action is justINSERT (cols) VALUES (...)withoutINTO. This is the same as what transactsql and plsql already do.MERGE_ACTION(PostgreSQL 17) to the function list, somerge_action()inRETURNINGisn't formatted asmerge_action ().Tests: the PostgreSQL suite now runs the shared
supportsMergeIntotest, plus a PostgreSQL-specific test coveringWHEN MATCHED AND ...,DELETE,DO NOTHING,BY SOURCE/BY TARGETandRETURNING merge_action().One side effect to note: because bare
INSERTis now a clause in PostgreSQL, something likeGRANT INSERT, UPDATE ON t TO bobbreaks beforeINSERTthe same way it already broke beforeUPDATE. Happy to narrow it down if you'd rather avoid that.pnpm test,pnpm ts:checkand prettier all pass locally.