Skip to content
This repository was archived by the owner on Nov 21, 2026. It is now read-only.

Record ids in rows: pin the contract both wheels share (tests and docs) - #530

Merged
tae898 merged 2 commits into
mainfrom
parity/record-id-values-jvm
Oct 25, 2026
Merged

tae898 merged 2 commits into
mainfrom
parity/record-id-values-jvm

Conversation

@tae898

@tae898 tae898 commented Oct 25, 2026

Copy link
Copy Markdown

A record id inside a row came back as two different things: the JVM wheel hands out the engine's own RID (a JPype object whose str() is #10:5), the native wheel a Python class of its own. A digest of the same query on both wheels showed it. This PR pins what the two have in common, so that code written against one runs on the other. The JVM wheel needs no code change: its behaviour is the contract.

The contract, written in docs/api/results.md under "Record ids in rows": a record id in a row value (SELECT @rid, a LINK property, a list of links) is an RID object; str(rid) is the text; RIDs of one record are equal and hash alike; RIDs sort by bucket and position; getBucketId(), getPosition(), toString() and isValid() work; it goes back in as a query parameter and to lookup_by_rid() as itself or as its text; get_rid() is text or None. I chose the object over text because the docs already said so (results.md: RIDs "over as the engine's own object"; record-wrappers.md: get_identity() is the RID object, "for a string RID use get_rid() or str(...)") and because the JVM wheel has more users whose code calls getBucketId() or passes the value straight back as a parameter. One thing is deliberately not part of the contract: rid == "#10:5" is False on the JVM wheel and True on the native wheel, so the docs say to compare str(rid).

Also fixed in the docs: lookup_by_rid is documented as taking an RID string, and it also takes the RID object a row holds (a docstring and database.md line, no code change). get_rid() now documents which rows have an identity (a record row, expand(), a projection of @rid without an alias).

The native side is a separate PR into native-preview (the native RID gets the missing methods and ordering, and Result.get_rid() takes a projected @rid), with the same test file and the same docs.

Local checks, all on this branch's last commit: tests/test_record_id_values.py 12 passed on the JVM wheel (new, shared with the native wheel); test_core.py, test_resultset.py, test_graph_api.py, test_docs_examples.py 91 passed (103 with the new file); pre-commit hooks (black, isort, whitespace, A/B tables) passed. Not run: the full suite and CI.

🤖 Generated with Claude Code

tae898 and others added 2 commits October 25, 2026 17:34
A record id inside a row (SELECT @Rid, a LINK property, a list of links) is an RID object on both wheels: str() is the text, equal RIDs hash alike, RIDs sort by bucket and position, getBucketId/getPosition/toString/isValid work, and an RID goes back in as a query parameter and to lookup_by_rid. get_rid() is text. The JVM wheel already behaves this way (its RID is the engine's own); the test file runs on both wheels and the docs state the contract and the one thing not to rely on (rid == "#10:5" is False on the JVM wheel).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@tae898
tae898 marked this pull request as ready for review October 25, 2026 08:54
@tae898
tae898 merged commit ad5997d into main Oct 25, 2026
50 of 52 checks passed
@tae898
tae898 deleted the parity/record-id-values-jvm branch October 25, 2026 10:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant