mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
Fix expression chaining
This commit is contained in:
parent
0f4e5ad26d
commit
91d4ac3ac0
3 changed files with 11 additions and 2 deletions
|
@ -290,6 +290,10 @@ pub fn json_type(value: &OwnedValue, path: Option<&OwnedValue>) -> crate::Result
|
|||
|
||||
/// Returns the value at the given JSON path. If the path does not exist, it returns None.
|
||||
/// If the path is an invalid path, returns an error.
|
||||
///
|
||||
/// *strict* - if false, we will try to resolve the path even if it does not start with "$"
|
||||
/// in a way that's compatible with the `->` and `->>` operators. See examples in the docs:
|
||||
/// https://sqlite.org/json1.html#the_and_operators
|
||||
fn json_extract_single<'a>(
|
||||
json: &'a Val,
|
||||
path: &OwnedValue,
|
||||
|
|
|
@ -457,9 +457,10 @@ pub fn translate_expr(
|
|||
match expr {
|
||||
ast::Expr::Between { .. } => todo!(),
|
||||
ast::Expr::Binary(e1, op, e2) => {
|
||||
let e1_reg = program.alloc_register();
|
||||
let e1_reg = program.alloc_registers(2);
|
||||
let e2_reg = e1_reg + 1;
|
||||
|
||||
translate_expr(program, referenced_tables, e1, e1_reg, resolver)?;
|
||||
let e2_reg = program.alloc_register();
|
||||
translate_expr(program, referenced_tables, e2, e2_reg, resolver)?;
|
||||
|
||||
match op {
|
||||
|
|
|
@ -331,6 +331,10 @@ do_execsql_test json_arrow_shift_implicit_real_cast {
|
|||
# SELECT '[1,2,3]' ->> false
|
||||
#} {{1}}
|
||||
|
||||
do_execsql_test json_arrow_chained {
|
||||
select '{"a":2,"c":[4,5,{"f":7}]}' -> 'c' -> 2 ->> 'f'
|
||||
} {{7}}
|
||||
|
||||
# TODO: fix me - this passes on SQLite and needs to be fixed in Limbo.
|
||||
do_execsql_test json_extract_multiple_null_paths {
|
||||
SELECT json_extract(1, null, null, null)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue