diff --git a/core/json/mod.rs b/core/json/mod.rs index 9a38e1879..eda97bf2b 100644 --- a/core/json/mod.rs +++ b/core/json/mod.rs @@ -173,13 +173,7 @@ pub fn json_extract(value: &OwnedValue, paths: &[OwnedValue]) -> crate::Result { - if paths.len() == 1 { - return Ok(OwnedValue::Null); - } else { - result.push_str("null,"); - } - } + OwnedValue::Null => return Ok(OwnedValue::Null), _ => crate::bail_constraint_error!("JSON path error near: {:?}", path.to_string()), } } diff --git a/testing/json.test b/testing/json.test index 39fce86de..5340f7049 100755 --- a/testing/json.test +++ b/testing/json.test @@ -125,13 +125,13 @@ do_execsql_test json_extract_object_3 { SELECT json_extract('{"a": [1,2,3]}', '$.a', '$.a[0]', '$.a[1]', null, '$.a[3]') } {{}} -# TODO: fix me -# \x61 is the ASCII code for 'a' +# TODO: fix me - this passes on SQLite and needs to be fixed in Limbo. +# \x61 is the ASCII code for 'a' # do_execsql_test json_extract_with_escaping { # SELECT json_extract('{"\x61": 1}', '$.a') # } {{1}} -# TODO: fix me +# TODO: fix me - this passes on SQLite and needs to be fixed in Limbo. #do_execsql_test json_extract_with_escaping_2 { # SELECT json_extract('{"\x61": 1}', '$.\x61') #} {{1}} @@ -140,12 +140,12 @@ do_execsql_test json_extract_null_path { SELECT json_extract(1, null) } {{}} -# TODO: fix me -#do_execsql_test json_extract_multiple_null_paths { -# SELECT json_extract(1, null, null, null) -#} {{[null,null,null]}} +# 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) +} {{}} -# TODO: fix me +# TODO: fix me - this passes on SQLite and needs to be fixed in Limbo. #do_execsql_test json_extract_quote { # SELECT json_extract('{"\"":1 }', '$.\"') #} {{1}} @@ -175,13 +175,13 @@ do_execsql_test json_extract_overflow_int64 { SELECT json_extract('[1,2,3]', '$[9223372036854775808]'); } {{1}} -# TODO: fix me? +# TODO: fix me - this passes on SQLite and needs to be fixed in Limbo. # pow(2, 127) + 1 == 170141183460469231731687303715884105729 #do_execsql_test json_extract_overflow_int128 { # SELECT json_extract('[1, 2, 3]', '$[170141183460469231731687303715884105729]'); #} {{2}} -# TODO: fix me +# TODO: fix me - this passes on SQLite and needs to be fixed in Limbo. #do_execsql_test json_extract_blob { # select json_extract(CAST('[1,2,3]' as BLOB), '$[1]') #} {{2}}