[WIP] Implement MERGE statement execution logic #2410
Draft
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.
Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.
Original prompt
This section details on the original issue you should resolve
<issue_title>UPSERT/MERGE Statement Not Implemented</issue_title>
<issue_description>## Summary
The MERGE statement syntax is parsed by AlaSQL (
src/75merge.js) but the execution logic is not implemented. Theexecute()method simply returns1without performing any insert, update, or delete operations. Additionally, PostgreSQL-styleINSERT ... ON CONFLICT(UPSERT) syntax is not supported.Current Behavior
Expected Behavior - MERGE Statement
Example 1: Basic MERGE with INSERT and UPDATE
Example 2: MERGE with DELETE
Example 3: MERGE with Conditional Logic
Expected Behavior - PostgreSQL UPSERT (ON CONFLICT)
Example 1: INSERT with UPDATE on Conflict
Example 2: INSERT with DO NOTHING on Conflict
Example 3: Conditional UPSERT
Use Cases
1. Synchronizing Data
2. Maintaining User Sessions
3. Deduplication
Implementation Status
Currently Parsed (src/75merge.js)
Not Implemented
1)💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.