mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-18 15:44:20 +01:00
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:
@@ -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 {
|
||||
|
||||
@@ -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(())
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user