Skip to content

SODA: save() / saveAndGet() upsert (#212)#214

Merged
lemenkov merged 1 commit into
masterfrom
soda-save-212
Jun 25, 2026
Merged

SODA: save() / saveAndGet() upsert (#212)#214
lemenkov merged 1 commit into
masterfrom
soda-save-212

Conversation

@lemenkov

Copy link
Copy Markdown
Owner

SODA follow-up: the upsert methods left out when the umbrella shipped (native DBMS_SODA save is ORA-03001 unimplemented in thin mode).

API (sync + async)

  • collection.save(doc) → upsert (insert, or replace the existing document with the same key); returns None
  • collection.saveAndGet(doc) → same, returning a SodaDocument with the resulting key / version / metadata

How

Emulated 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.

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

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>
@lemenkov lemenkov added this to the 1.10.1 milestone Jun 25, 2026
@lemenkov
lemenkov merged commit c4d3058 into master Jun 25, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SODA: save() / saveAndGet() upsert

1 participant