mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-12 03:34:20 +01:00
support parenthesized(single expr) in translate_expr()
This commit is contained in:
@@ -536,6 +536,8 @@ pub fn translate_condition_expr(
|
||||
}
|
||||
}
|
||||
ast::Expr::Parenthesized(exprs) => {
|
||||
// TODO: this is probably not correct; multiple expressions in a parenthesized expression
|
||||
// are reserved for special cases like `(a, b) IN ((1, 2), (3, 4))`.
|
||||
for expr in exprs {
|
||||
let _ = translate_condition_expr(
|
||||
program,
|
||||
@@ -1470,7 +1472,26 @@ pub fn translate_expr(
|
||||
},
|
||||
ast::Expr::Name(_) => todo!(),
|
||||
ast::Expr::NotNull(_) => todo!(),
|
||||
ast::Expr::Parenthesized(_) => todo!(),
|
||||
ast::Expr::Parenthesized(exprs) => {
|
||||
if exprs.is_empty() {
|
||||
crate::bail_parse_error!("parenthesized expression with no arguments");
|
||||
}
|
||||
if exprs.len() == 1 {
|
||||
translate_expr(
|
||||
program,
|
||||
referenced_tables,
|
||||
&exprs[0],
|
||||
target_register,
|
||||
cursor_hint,
|
||||
cached_results,
|
||||
)?;
|
||||
} else {
|
||||
// Parenthesized expressions with multiple arguments are reserved for special cases
|
||||
// like `(a, b) IN ((1, 2), (3, 4))`.
|
||||
todo!("TODO: parenthesized expression with multiple arguments not yet supported");
|
||||
}
|
||||
Ok(target_register)
|
||||
}
|
||||
ast::Expr::Qualified(tbl, ident) => {
|
||||
let (idx, col_type, cursor_id, is_primary_key) = resolve_ident_qualified(
|
||||
program,
|
||||
|
||||
@@ -583,6 +583,10 @@ impl Program {
|
||||
(OwnedValue::Float(lhs), OwnedValue::Float(rhs)) => {
|
||||
state.registers[dest] = OwnedValue::Float(lhs + rhs);
|
||||
}
|
||||
(OwnedValue::Float(f), OwnedValue::Integer(i))
|
||||
| (OwnedValue::Integer(i), OwnedValue::Float(f)) => {
|
||||
state.registers[dest] = OwnedValue::Float(*f + *i as f64);
|
||||
}
|
||||
(OwnedValue::Null, _) | (_, OwnedValue::Null) => {
|
||||
state.registers[dest] = OwnedValue::Null;
|
||||
}
|
||||
|
||||
@@ -50,3 +50,7 @@ do_execsql_test table-star-2 {
|
||||
do_execsql_test seekrowid {
|
||||
select * from users u where u.id = 5;
|
||||
} {"5|Edward|Miller|christiankramer@example.com|725-281-1033|08522 English Plain|Lake Keith|ID|23283|15"}
|
||||
|
||||
do_execsql_test select_parenthesized {
|
||||
select (price + 100) from products limit 1;
|
||||
} {179.0}
|
||||
Reference in New Issue
Block a user