Repository navigation
fix(databases): honor record id on transaction upsert - #14197
HarshMN2345 wants to merge 2 commits into
Conversation
Security rulesNo new WARNING or ERROR findings from security rules. 32 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Staged upsert kept the record id off the document, so commit inserted a new row. Copy that id onto the document before upsert, and reject a staged operation whose data $id names a different record.
Copy the staged id onto the document whenever it is set, and reject a different data $id with the same bad-request style as the other operation checks. The e2e reads the updated row before a later upsert and asserts the list did not gain a row.
5dbbc93 to
e989e83
Compare
|
@hansi-codes review |
🟢 Tier S · Ready to merge
Transaction upsert now copies the staged record ID into the document passed to the database, so commits target the requested row rather than generating a new ID. Staging rejects conflicting IDs in operation data, and shared E2E coverage checks updates, inserts, matching IDs, and mismatch rejection.
📂 Walkthrough · 3
Reviewed |
What does this PR do?
Transaction upsert staged through
createOperationsstoredrowId/documentIdon the operation and built the document fromdataalone.upsertDocument()identifies the row by$id, so a commit inserted a new row with a generated id and left the requested row unchanged.Commit now copies the staged record id onto the document before upsert. That is the id the permission check and the post-commit event already use. An operation whose
data.$idnames a different record is rejected when it is staged (general_bad_request). A matching$idis unchanged.Fixes #14178.
Test Plan
testUpsertOperationRecordIdupdates an existing record with the id only on the operation. After commit the same id has the new values and the list total stays 1.data.$idrepeats the operation id. The list contains exactly those two ids.data.$iddiffer returns400general_bad_requestand does not change the existing record.Related PRs and Issues
Checklist