Repository navigation
Conversation
…nd walks Node rows are keyed by (kind, id), but a recursive traversal that could visit more than one kind used the bare node id as its cycle-detection and path token unless identity expansion was on. Reaching a node whose id matched an earlier node of a different kind on the same path read as a revisit, so that node and everything beyond it were silently omitted. The token shape is now decided by one owner, recursivePathTokenShape (src/query/compiler/recursive-path-token.ts): kind-qualified whenever the walk's start kinds plus step kinds hold more than one kind, or identity members are expanded; bare id otherwise. The recursive compiler and the path materializer both call it from the same inputs, so the materializer strips composite tokens exactly when the compiler emitted them. Single-kind walks compile to byte-identical SQL, and path output stays an array of bare node ids.
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.
Node rows are keyed by (kind, id), so two nodes of different kinds may share an id. The recursive traversal compiler used the bare node id as its per-step cycle-detection and path token unless identity expansion was on. Any recursive walk able to visit more than one kind therefore read a node whose id matched an earlier node of another kind on the same path as a revisit, and silently omitted it and everything beyond it. For example,
from("Show").traverse("linked").recursive().to("Clip")returned nothing when the Show and the Clip shared an id.The token shape now has one owner,
recursivePathTokenShapeinsrc/query/compiler/recursive-path-token.ts. It is kind-qualified (kind || U+001F || id) whenever the walk's source kinds plus step kinds contain more than one kind, or identity members are expanded, and the bare id otherwise. The recursive compiler and the path materializer (transformPathColumns) both call it with the same inputs: the materializer resolves a traversal's source kinds through the samegetNodeKindsForAliasthe compiler uses, including for later composed recursive stages, so it strips composite tokens exactly when the compiler emitted them. The worktable kind column and the column-pruning requirement go through the same owner. Single-kind walks and identity-expanded walks compile to byte-identical SQL.pathoutput stays an array of bare node ids, and qualified paths are unchanged.Two existing tests asserted the old behavior: a non-identity Person→Company control walk that stopped short at a same-id peer now reaches it, and a SQL-shape test for a Person→Organization walk now expects the kind-qualified token.
store.subgraphhas a broader form of the same conflation (its whole walk and result map are id-keyed), which needs a result-shape decision and is tracked in #791.The new cross-backend cases in
tests/backends/integration/recursive-shared-ids.tsfail on main and pass with the fix. Mutating the owner back to the identity-only rule fails them, and forcing the materializer to always strip fails the separator-bearing-id case.