fix(oracle): restrict upsert update to the conflicting row - #18417
Draft
wikirik-agent wants to merge 1 commit into
Draft
wikirik-agent wants to merge 1 commit into
wikirik-agent wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 5 <[email protected]>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
wikirik-agent
added this pull request to stack #18421
September 17, 2026 15:14
This was referenced Sep 17, 2026
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.
Pull Request Checklist
Description of Changes
When
Model.upsert()is called without a primary key value, core passes an emptywhereto the dialect (Model.upsertusesinstance.where(false, true) ?? {}). The Oracle query interface only built its own condition from the upsert keys when the primary key inwherewasnull, which no longer happens. The emptywherereachedupsertQuery, which generated anUPDATEwithout aWHEREclause. Every row in the table was overwritten, and becauseSQL%ROWCOUNT > 0, the new row was never inserted:An existing unit test expected exactly that unrestricted
UPDATE. Other dialects are not affected.This PR:
where, as long as every key has a value;UPDATE. This matches postgres and sqlite, whereON CONFLICT ("id")always inserts when the id is generated.Tests
model/upsert.test.js, all dialects that support upserts): upserting by a unique column only updates the matching row. It fails on Oracle before this change and passes on postgres, mysql, mariadb, mssql, sqlite3, db2 and oracle after it.Follow-ups found while working on this are stacked on top: #18419 makes Oracle's upsert return the row like the other dialects, and #18420 adds
conflictFieldssupport.List of Breaking Changes
None.
🤖 Generated with Claude Code