fix(hql): property access causing codegen failure #851
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.
Fixes #847
Greptile Overview
Greptile Summary
Fixes Rust codegen failure for WHERE clauses with multi-step traversals before property access (e.g.,
_::ToN::ID::EQ(id)).The existing code generation only handled 2-step patterns (property access + boolean operation), causing compilation failures when traversal steps like
ToNorFromNpreceded property access. This PR extends the pattern matching to handle 3+ step traversals by:filter_refclosures that useG::from_iterto execute the traversal chain before property evaluationReservedPropertyAccess(ID, Label) andPropertyFetch(custom properties)The fix includes comprehensive test coverage for
ToN,FromNtraversals with various property types and regression tests for simple cases.Important Files Changed
_::ToN::ID::EQ(id)), extending existing 2-step pattern handling to 3+ stepsToN,FromNtraversals with both reserved properties (ID) and custom properties, plus regression testsSequence Diagram
sequenceDiagram participant HQL as HQL Query Parser participant TGen as Traversal Code Generator participant WhereRef as WhereRef Display participant RustCode as Generated Rust Code Note over HQL,RustCode: Example: WHERE(_::ToN::ID::EQ(id)) HQL->>TGen: Parse traversal steps<br/>[_, ToN, ID, EQ(id)] TGen->>WhereRef: Display WhereRef with traversal alt 2-step pattern (existing) Note over WhereRef: Pattern: _::ID::EQ(id) WhereRef->>WhereRef: Check traversal.steps.len() == 2 WhereRef->>WhereRef: Extract ReservedPropertyAccess + BoolOp WhereRef->>RustCode: Generate filter_ref with direct val access else 3+ step pattern (NEW FIX) Note over WhereRef: Pattern: _::ToN::ID::EQ(id) WhereRef->>WhereRef: Check traversal.steps.len() > 2 WhereRef->>WhereRef: Extract last step (BoolOp) WhereRef->>WhereRef: Extract second-last step (PropertyAccess/ReservedProp) WhereRef->>WhereRef: Extract prefix steps ([_, ToN]) alt ReservedPropertyAccess (ID/Label) WhereRef->>RustCode: Generate filter_ref with:<br/>1. G::from_iter for traversal<br/>2. node.id()/label() access<br/>3. Boolean comparison else PropertyFetch ({property}) WhereRef->>RustCode: Generate filter_ref with:<br/>1. G::from_iter for traversal<br/>2. node.get_property() access<br/>3. Boolean expression end else Fallback WhereRef->>RustCode: Generate unoptimized filter_ref end RustCode->>RustCode: Compile generated Rust code