Skip to content

Check a lookup by id and a save's lookup read layout 2's index, and a step without the id's JSON is refused by name - #590

Merged
jasperblues merged 2 commits into
mainfrom
node-id-lookup-509
Nov 25, 2026
Merged

jasperblues merged 2 commits into
mainfrom
node-id-lookup-509

Conversation

@jasperblues

Copy link
Copy Markdown
Member

This adds the last tests from drivine4j's NodeIdLookupCrossEngineTest: they check that each lookup of a node by its @NodeId reads store layout 2's index, and that Postgres's write function refuses a plan step that doesn't carry the id. The behaviour itself is already on main: #533 made every load, delete, related, held-properties and found-stamp lookup by id use the shared module's hasId, read a text id as the id's type, keyed a temporal id by its tag's text, and made SQLite's plan writer find by the id's JSON. #536 made Oracle's write blocks find nodes the same way, and #518 made ref and patch steps carry the id. No code and no golden statements change.

What the tests check

In tests/integration/sql/test_node_id_lookup.py, async and sync:

  • A lookup by a str id reads its uniqueness constraint's index on Postgres and SQLite: the load, the delete by id and load_related, as the number and date ids already did.
  • A save's lookup on Postgres reads the index. The write function finds each node through the statement drivine_find prepares on its connection. Called inside one transaction, so on one connection, the prepared statement is explained for the id's JSON, for a number, a date and a str id. Each must be an index scan of the id's uniqueness constraint, with an index condition on props -> 'id' and no sequential scan of the nodes.
  • A ref or patch step without the id's JSON is refused by name by drivine_write: "A plan step that finds a node by id carries no id". Before, such a step would find no node and read as absent.

Oracle's lookup plans are tested in drivine4j's suite, as this file's existing index tests note. drivine4j has no Oracle save-lookup or refused-step test.

loadNearestAmong's cases aren't ported. That method is only in drivine4j.

Closes #509.

Testing

  • Postgres, Oracle and SQLite: tests/integration/sql/test_node_id_lookup.py 131 passed, 10 skipped; tests/sync_integration/sql/test_node_id_lookup.py 131 passed, 10 skipped. The skips are the store-specific cases (each test says which store it's for).
  • ruff, ruff format --check, pyright and unasync --check are clean.

Review: 2 passes, last CLEAN.

  • Pass 1 made the save-lookup check require the index condition on the id, so a scan of the whole index can't pass it. It also reused the tests' own SQL literal and error-chain helpers.
  • Pass 2: CLEAN.

…ndex, and a step without the id's JSON is refused by name
@jasperblues
jasperblues merged commit 4b4bdfc into main Nov 25, 2026
16 checks passed
@jasperblues jasperblues mentioned this pull request Nov 26, 2026
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.

Layout 2 at 0.48.1: ref and patch steps carry the id's JSON; find nodes by id as the index is made over it

1 participant