SODA: save() / saveAndGet() upsert (#212)#214
Merged
Merged
Conversation
DBMS_SODA's native save is ORA-03001 "unimplemented feature" in thin mode, so emulate the upsert in one round trip: when the document carries a key, replace_one_and_get by that key and fall back to insert_one_and_get if nothing matched; with no key, insert. save() returns None; saveAndGet() returns a SodaDocument with the resulting key / version / metadata. Verified on both keying models (23ai embedded-OID, 21c UUID): an existing key replaces in place (count unchanged), a new document inserts. Sync + async; 23ai/21c pass, 11g/9i skip. Closes #212 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
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.
SODA follow-up: the upsert methods left out when the umbrella shipped (native DBMS_SODA
saveis ORA-03001 unimplemented in thin mode).API (sync + async)
collection.save(doc)→ upsert (insert, or replace the existing document with the same key); returns Nonecollection.saveAndGet(doc)→ same, returning aSodaDocumentwith the resulting key / version / metadataHow
Emulated in one round trip: when the document carries a key,
replace_one_and_getby that key and fall back toinsert_one_and_getif nothing matched; with no key, insert.Tests: verified on both keying models — 23ai embedded-OID and 21c UUID — that an existing key replaces in place (count unchanged) and a new document inserts. Sync + async; 23ai/21c pass, 11g/9i skip. Offline 527.
Closes #212
🤖 Generated with Claude Code