this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix WHERE clause parsing to support property access

🐛 BUG FIX:
- Add property access parsing (a.name) to primary_expression parser
- WHERE clauses with property comparisons now parse correctly
- Support for compound WHERE conditions with AND/OR operators

✅ IMPROVEMENTS:
- Can now parse: WHERE a.name = 'Alice'
- Can now parse: WHERE a.name = 'Alice' AND b.name = 'Bob'
- Add test coverage for WHERE clause parsing

🚧 KNOWN ISSUE:
- WHERE clauses parse correctly but don't filter results yet
- Execution logic needs to be implemented to actually apply WHERE filters
- This commit only fixes the parsing error, not the execution

BEFORE:
Error: Query parsing failed: Unexpected tokens after query: [Dot, Identifier("name"), ...]

AFTER:
Query parses successfully (though filtering not yet implemented)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

+44
+4
.gigabrain_history
··· 11 11 CREATE (bob:Person {name: 'Bob', age: 25}) 12 12 MATCH (n) RETURN n 13 13 :exit 14 + CREATE (alice:Person {name: 'Alice', age: 30}) 15 + CREATE (bob:Person {name: 'Bob', age: 25}) 16 + MATCH (a:Person), (b:Person) WHERE a.name = 'Alice' AND b.name = 'Bob' 17 + :exit
+13
src/cypher/parser.rs
··· 324 324 325 325 fn primary_expression(input: Tokens) -> IResult<Tokens, Expression> { 326 326 alt(( 327 + // Try property access first (a.name) 328 + map( 329 + tuple(( 330 + identifier, 331 + |i| expect_token(i, &Token::Dot), 332 + identifier, 333 + )), 334 + |(obj, _, prop)| Expression::Property(PropertyExpression { 335 + expression: Box::new(Expression::Variable(obj)), 336 + property: prop, 337 + }), 338 + ), 339 + // Then literals and simple variables 327 340 map(literal, |lit| Expression::Literal(lit)), 328 341 map(identifier, Expression::Variable), 329 342 delimited(
+27
tests/cypher_execution_tests.rs
··· 110 110 Ok(()) 111 111 } 112 112 113 + #[tokio::test] 114 + async fn test_where_clause_parsing() -> TestResult { 115 + let graph = Arc::new(Graph::new()); 116 + let executor = QueryExecutor::new(graph.clone()); 117 + 118 + // Create test data 119 + let create_alice = parse_cypher("CREATE (alice:Person {name: 'Alice', age: 30})")?; 120 + let create_bob = parse_cypher("CREATE (bob:Person {name: 'Bob', age: 25})")?; 121 + 122 + executor.execute_query(&create_alice).await?; 123 + executor.execute_query(&create_bob).await?; 124 + 125 + // Test WHERE clause with property access 126 + let where_query = parse_cypher("MATCH (p:Person) WHERE p.name = 'Alice' RETURN p")?; 127 + // For now, just ensure it parses without error 128 + let _result = executor.execute_query(&where_query).await?; 129 + 130 + // Test compound WHERE with AND 131 + let compound_where = parse_cypher( 132 + "MATCH (a:Person), (b:Person) WHERE a.name = 'Alice' AND b.name = 'Bob' RETURN a, b" 133 + )?; 134 + // For now, just ensure it parses without error 135 + let _result = executor.execute_query(&compound_where).await?; 136 + 137 + Ok(()) 138 + } 139 + 113 140 /// Test CLI integration specifically 114 141 #[tokio::test] 115 142 async fn test_cli_query_execution() -> TestResult {