Add first-class Cypher query parameter support for read execution#23
Conversation
Agent-Logs-Url: https://github.com/sunsided/petgraph-decypher/sessions/e1b7ebd2-3439-4275-9e37-e0d1726f3503 Co-authored-by: sunsided <495335+sunsided@users.noreply.github.com>
Agent-Logs-Url: https://github.com/sunsided/petgraph-decypher/sessions/e1b7ebd2-3439-4275-9e37-e0d1726f3503 Co-authored-by: sunsided <495335+sunsided@users.noreply.github.com>
Agent-Logs-Url: https://github.com/sunsided/petgraph-decypher/sessions/e1b7ebd2-3439-4275-9e37-e0d1726f3503 Co-authored-by: sunsided <495335+sunsided@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds first-class support for named Cypher parameters ($name) in read query execution so callers can safely run parameterized MATCH/WHERE/RETURN queries without string interpolation, while keeping existing cypher(&str) entrypoints working.
Changes:
- Introduces a public
Parametersalias and new parameterized read APIs (cypher_params,cypher_with_strategy_params). - Threads parameters through expression evaluation (WHERE/projection/function args/ORDER BY) and adds pre-execution “missing parameter” validation.
- Adds integration tests covering parameter usage and missing-parameter error behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/query.rs |
Adds Parameters, new parameterized read methods, pre-validation for missing params, and parameter-aware expression evaluation. |
src/lib.rs |
Re-exports Parameters from the crate root. |
tests/query_tests.rs |
Adds integration tests for parameters in WHERE/RETURN/function args and missing-parameter errors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/sunsided/petgraph-decypher/sessions/49a9a0cc-7b9b-4921-9b23-67d9ba2ccd3f Co-authored-by: sunsided <495335+sunsided@users.noreply.github.com>
Agent-Logs-Url: https://github.com/sunsided/petgraph-decypher/sessions/49a9a0cc-7b9b-4921-9b23-67d9ba2ccd3f Co-authored-by: sunsided <495335+sunsided@users.noreply.github.com>
Agent-Logs-Url: https://github.com/sunsided/petgraph-decypher/sessions/49a9a0cc-7b9b-4921-9b23-67d9ba2ccd3f Co-authored-by: sunsided <495335+sunsided@users.noreply.github.com>
Applied the review-thread fixes in commit |
Cypher parameters (
$name) were already represented in the AST but rejected at runtime, which prevented safe parameterized queries. This PR adds read-query parameter support across filtering and projection while preserving existingcypher(&str)APIs.API additions (source-compatible)
Parameterstype alias (HashMap<String, CypherValue>) for named query parameters.cypher_params(&self, query, ¶meters)cypher_with_strategy_params(&self, query, strategy, ¶meters)cypher(...)andcypher_with_strategy(...)remain unchanged and continue to work without parameters.PetgraphCypher,PetgraphCypherRead) to keep downstream trait implementors source-compatible.Execution engine wiring
WHEREevaluation, projection (RETURN), sort expression evaluation, and function argument evaluation.Expression::Parameterresolution from the provided parameter map.Validation and error behavior
MATCH/OPTIONAL MATCHWHERE,RETURN,UNWIND,ORDER BY).CypherError::InvalidQuery("missing query parameter: $<name>")cypher_mut) now explicitly reject parameter usage with a clear error:CypherError::Unsupported("query parameters are not supported in cypher_mut(): $<name>")Tests for acceptance criteria and compatibility
WHERERETURNcypher_mutExample usage: