Merge 'Add support for parenthesized conditions' from Kim Seon Woo

### Motivation
Add support for WHERE parenthesized conditions
- closes #153

Closes #338
This commit is contained in:
Pekka Enberg
2024-09-21 12:27:18 +03:00
3 changed files with 27 additions and 2 deletions

View File

@@ -248,7 +248,7 @@ pub enum PageType {
}
impl TryFrom<u8> for PageType {
type Error = crate::error::LimboError;
type Error = LimboError;
fn try_from(value: u8) -> Result<Self> {
match value {

View File

@@ -537,6 +537,17 @@ pub fn translate_condition_expr(
);
}
}
ast::Expr::Parenthesized(exprs) => {
for expr in exprs {
let _ = translate_condition_expr(
program,
referenced_tables,
expr,
cursor_hint,
condition_metadata,
);
}
}
_ => todo!("op {:?} not implemented", expr),
}
Ok(())

View File

@@ -252,4 +252,18 @@ do_execsql_test where_multiple {
do_execsql_test where_multiple_flipped {
select id, first_name, age from users where age < 50 and id = 5;
} {5|Edward|15}
} {5|Edward|15}
do_execsql_test where-parentheses-and {
select id, name from products where (id = 5 and name = 'sweatshirt') and (id = 5 and name = 'sweatshirt') ORDER BY id;
} {5|sweatshirt}
do_execsql_test where-nested-parentheses {
select id, name from products where ((id = 5 and name = 'sweatshirt') or (id = 1 and name = 'hat')) ORDER BY id;
} {1|hat
5|sweatshirt}
do_execsql_test where-complex-parentheses {
select id, name from products where ((id = 5 and name = 'sweatshirt') or (id = 1 and name = 'hat')) and (name = 'sweatshirt' or name = 'hat') ORDER BY id;
} {1|hat
5|sweatshirt}