Repository navigation
Docs: a Values and records page, with tests that pin each statement first (refs #267) - #281
Merged
Merged
Conversation
…irst (refs #267) Second slice of #267, rows 3 (types and datetimes), 9 (record objects) and 12 (the Schema API line). The tests come first. tests/test_values_and_records_behavior.py pins, on both builds and with SQL and wrapper objects only, how Python values go in and what comes back (scalars, the declared type winning over the Python type, Decimal, naive and aware datetime, the precision of DATETIME_SECOND, DATETIME and DATETIME_MICROS, date, bytes as signed ints, tuples, dicts, sets until the commit, an embedded document), what a query row and a record object give (methods only, no item access or attributes, to_dict is a new dict), that a record or row is the record as it was read, modify() and a stale save, identity, lookup_by_key and the Schema API next to SQL. Most statements were already covered one by one in older tests; the new file holds them in the form the page states them. The page how-to/values-and-records.adoc says only what those tests prove, and tests/test_docs_values_page.py runs every Python block of the page on both builds and checks the printed output, in the pattern of the transactions page. The nav gets one line, and Databases and queries and the quickstart link to the page. A [[record-ids-in-rows]] anchor is added to Databases and queries for the link. Tests could not run on the laptop (CI runs them), so each assertion comes from reading type_conversion.py, graph.py, results.py and the native codec, records and schema code, and from the existing tests that pin the same behavior. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…, pin the unbacked sentences (refs #267) CI run 42155789721 failed one test: on the JVM build to_dict() and to_list() give an embedded document as the engine's own Java object (ImmutableEmbeddedDocument), not a dict. The native codec writes it as a JSON object with its @type (NativeCodec.appendDocument), so it is a dict there. The test now states that per backend, and the page says it once in the types section and in the short version; a dotted path in the statement (SELECT em.q) reads a member as a plain value on both and is pinned. The editorial patch is applied. Where it left a sentence with no test, a test now pins it (bytearray as a list of signed ints, get_both_edges with a label, a RID object from a row passed to lookup_by_rid, a composite index for lookup_by_key, plain DROP TYPE refusing a graph type with records while UNSAFE and drop_type drop it); two sentences that no test pins are cut: that a list or dict from get() is not a live view (the native build returns the held object), and that lookup_by_key goes in the index's order and returns the first match. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.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 slice of #267 (audit of the docs against 26.11.1). It covers row 3 (types and datetimes), row 9 (record objects) and row 12 (the
SchemaAPI line), in one new page,how-to/values-and-records.adoc.Tests first:
tests/test_values_and_records_behavior.pypins, with SQL and wrapper objects only, how Python values go in and what comes back (scalars, the declared type winning over the Python type,Decimal, naive and awaredatetime, the precision ofDATETIME_SECOND,DATETIMEandDATETIME_MICROS,date, bytes as signed ints, tuples, dicts, sets until the commit, an embedded document), what a query row and a record object give (methods only, no item access or attributes,to_dict()is a new dict), that a record or row is the record as it was read,modify(),save()and a stale save, identity,lookup_by_key, and theSchemaAPI next to SQL. Several of these statements were already pinned one by one in older tests (test_type_conversion.py,test_graph_api.py,test_schema.py); the new file holds them in the form the page states them. The page says only what those tests prove, andtests/test_docs_values_page.pyruns every Python block of the page on both builds and checks the printed output, in the pattern of the transactions page. The nav gets one line, and Databases and queries and the quickstart link to the page (a[[record-ids-in-rows]]anchor was added for that link).I could not run the tests on the laptop (CI runs them), so the assertions came from reading
type_conversion.py,graph.py,results.pyand the native codec, records and schema code, plus the older tests above. The Antora build of the component passes locally with no warning. The first CI run found one wrong statement (the embedded document above) and it is fixed here. The JVM test workflow on the current head passes (24 of 24 jobs); the native parity legs run now that the PR is ready.Behavior worth a look, none of it filed:
Result.get()andDocument.get()return the object the row or record holds, andto_dict()is a shallow copy, so changing a list or dict you got back changes what the same row or record returns next. On the JVM build everyget()converts afresh, so it does not. Read from_native/database.pyand_native/records.py, not run: the page only says that such a change is never stored.Document.get_rid()of a record that was never saved returns"#-1:-1"on the native build; on the JVM build it isstr(None)by my reading ofgraph.py(the identity is null untilsave()). The page and the tests only useget_rid()aftersave().Document, aVertexand anEdgehave no__eq__: two reads of one record are two unequal objects, and a row has no__getitem__or attribute access, sorow["name"]raisesTypeError. That is documented as is.bytes, and a set comes back as a list after the commit. Both are stated as they are.to_dict()andto_list()give the engine's own Java object (ImmutableEmbeddedDocument) for a nested embedded document, not a dict. On the native build the source gives a dict with an@typemember. The page says this once, per build, and points to the dotted path in the statement (SELECT em.q AS q), which returns the plain value on both.Schemacreate and get methods return a Java object on the JVM build and a placeholder on the native build, so the page tells readers not to use the return value. That sentence comes from the source and has no test.get_or_create_propertyon the JVM build passes the type name to the engine without upper-casing it (create_propertyupper-cases); the page uses upper-case names and does not rely on this.Left of #267: row 4 (import and export) and row 5 (DataFrame, Arrow and columns) are on the other open branch; rows 8 (Python functions and events), 10 (
set_wal_flush,fileSync,txWalGroupCommit) and 11 (AsyncExecutor) are not started. Rows 6, 7 and 13 and the stale statements were planned for #264 and #276; I did not re-check them againstmain.Refs #267
🤖 Generated with Claude Code