SODA: document model + insert + read by key (#200)#207
Merged
Conversation
Second step of the #163 SODA umbrella, on top of the collection foundation (#199). Adds the document layer over DBMS_SODA: - SodaDatabase.createDocument(content, key=None, mediaType=...) builds a client-side SodaDocument; content may be a dict (-> JSON), str or bytes. - SodaCollection.insertOne(doc) and insertOneAndGet(doc) -> a SodaDocument carrying the server key / version / media type / timestamps (no content, matching oracledb). Both accept a SodaDocument or a bare content value. - SodaCollection.find().key(k).getOne() reads a document back by key (None if absent); SodaOperation is the read-builder that QBE / multi-doc reads extend in #201. - SodaDocument: key / version / mediaType / createdOn / lastModified and getContent() (JSON -> Python value) / getContentAsString() / getContentAsBytes(). Content is bound as bytes, so inserting a document over the 32767-byte PL/SQL limit rides the transparent temp-LOB bind (#91). Reading content comes through one DBMS_LOB.SUBSTR and is capped at 32767 bytes — a larger stored document raises NotSupportedError rather than silently truncating (chunked large reads are a follow-up). RE notes: get_created_on / get_last_modified return VARCHAR2 ISO strings (not timestamps), and the default collection shape differs by server (23ai native-JSON + embedded-OID key; 21c BLOB/JSON + UUID key + tracked timestamps) — covered by tests on both. Sync + async; 23ai/21c pass, 11g/9i skip. Closes #200 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.
Second step of the #163 SODA umbrella, on top of the collection foundation (#199). Adds the document layer over
DBMS_SODA.API (sync + async)
SodaDatabase.createDocument(content, key=None, mediaType="application/json")→ a client-sideSodaDocument(content may be a dict → JSON, str, or bytes).SodaCollection.insertOne(doc)/insertOneAndGet(doc)→ aSodaDocumentwith the server key / version / mediaType / createdOn / lastModified (no content, matching oracledb). Both accept aSodaDocumentor a bare value.SodaCollection.find().key(k).getOne()→ read a document by key (Noneif absent).SodaOperationis the read-builder that QBE / multi-doc reads extend in SODA: query-by-example (QBE) find #201.SodaDocument:getContent()(JSON → Python value) /getContentAsString()/getContentAsBytes(), plus the metadata fields.Content size
Content binds as bytes, so inserting a document over the 32767-byte PL/SQL limit rides the transparent temp-LOB bind (#91). Reading content comes through one
DBMS_LOB.SUBSTRand is capped at 32767 bytes — a larger stored document raisesNotSupportedErrorrather than silently truncating (chunked large reads are a follow-up).RE notes
get_created_on/get_last_modifiedreturn VARCHAR2 ISO strings, not timestamps (ato_char(…, datefmt)over them is ORA-06502 on 21c).Tests: offline document/content helpers; live insert + read-by-key + large-doc guard, sync + async — 23ai/21c pass, 11g/9i skip. Offline suite 526.
Closes #200
🤖 Generated with Claude Code