You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add comprehensive tests for complex WHERE clauses with parentheses
Added 10 new tests covering various trade query patterns including:
- Basic parenthesized OR conditions (status = "active" OR status = "pending")
- Mixed AND/OR with parentheses ((symbol = "AAPL" OR symbol = "GOOGL") AND price > 100)
- Nested parentheses for complex logic
- Multiple OR groups with AND
- String methods inside parentheses (symbol.StartsWith patterns)
- Date range queries with DateTime comparisons
- Price/volume filtering with nested ranges
- Triple nested conditions
- Parentheses around AND chains
These tests ensure the parser correctly handles the complex WHERE clauses
commonly used in trade data analysis and filtering.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
r#"SELECT * FROM trades WHERE (executionDate > DateTime(2024, 1, 1) AND executionDate < DateTime(2024, 12, 31)) AND (status = "filled" OR status = "partial")"#
r#"SELECT * FROM trades WHERE ((price > 100 AND price < 200) OR (price > 500 AND price < 1000)) AND volume > 10000"#
1998
+
);
1999
+
let stmt = parser.parse().unwrap();
2000
+
2001
+
assert!(stmt.where_clause.is_some());
2002
+
let where_clause = stmt.where_clause.unwrap();
2003
+
2004
+
// Should handle nested price ranges with OR
2005
+
assert!(where_clause.conditions.len() > 0);
2006
+
}
2007
+
2008
+
#[test]
2009
+
fntest_complex_where_mixed_string_numeric(){
2010
+
// Mix of string comparisons and numeric comparisons in groups
2011
+
letmut parser = Parser::new(
2012
+
r#"SELECT * FROM trades WHERE (exchange = "NYSE" OR exchange = "NASDAQ") AND (volume > 1000000 OR notes.Contains("urgent"))"#
2013
+
);
2014
+
let stmt = parser.parse().unwrap();
2015
+
2016
+
assert!(stmt.where_clause.is_some());
2017
+
// Should parse without errors
2018
+
}
2019
+
2020
+
#[test]
2021
+
fntest_complex_where_triple_nested(){
2022
+
// Very complex nesting - ((a OR b) AND (c OR d)) OR (e AND f)
2023
+
letmut parser = Parser::new(
2024
+
r#"SELECT * FROM trades WHERE ((symbol = "AAPL" OR symbol = "GOOGL") AND (price > 100 OR volume > 1000000)) OR (status = "cancelled" AND reason.Contains("timeout"))"#
2025
+
);
2026
+
let stmt = parser.parse().unwrap();
2027
+
2028
+
assert!(stmt.where_clause.is_some());
2029
+
// Should handle triple nesting correctly
2030
+
}
2031
+
2032
+
#[test]
2033
+
fntest_complex_where_single_parens_around_and(){
2034
+
// Parentheses around AND conditions
2035
+
letmut parser = Parser::new(
2036
+
r#"SELECT * FROM trades WHERE (symbol = "AAPL" AND price > 150 AND volume > 100000)"#
2037
+
);
2038
+
let stmt = parser.parse().unwrap();
2039
+
2040
+
assert!(stmt.where_clause.is_some());
2041
+
let where_clause = stmt.where_clause.unwrap();
2042
+
2043
+
// Should correctly parse the AND chain inside parentheses
0 commit comments