mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
Add support for json_extract
This commit is contained in:
parent
82bc9501fd
commit
ad9acf7400
10 changed files with 893 additions and 468 deletions
|
@ -83,3 +83,90 @@ do_execsql_test json_array_json {
|
|||
do_execsql_test json_array_nested {
|
||||
SELECT json_array(json_array(1,2,3), json('[1,2,3]'), '[1,2,3]')
|
||||
} {{[[1,2,3],[1,2,3],"[1,2,3]"]}}
|
||||
|
||||
|
||||
do_execsql_test json_extract_null {
|
||||
SELECT json_extract(null, '$')
|
||||
} {{}}
|
||||
|
||||
do_execsql_test json_extract_empty {
|
||||
SELECT json_extract()
|
||||
} {{}}
|
||||
|
||||
do_execsql_test json_extract_single_param {
|
||||
SELECT json_extract(1)
|
||||
} {{}}
|
||||
|
||||
do_execsql_test json_extract_null_invalid_path {
|
||||
SELECT json_extract(null, 1)
|
||||
} {{}}
|
||||
|
||||
do_execsql_test json_extract_null_invalid_path_2 {
|
||||
SELECT json_extract(null, CAST(1 AS BLOB))
|
||||
} {{}}
|
||||
|
||||
do_execsql_test json_extract_multiple_nulls {
|
||||
SELECT json_extract(null, CAST(1 AS BLOB), null, 1, 2, 3)
|
||||
} {{}}
|
||||
|
||||
do_execsql_test json_extract_number {
|
||||
SELECT json_extract(1, '$')
|
||||
} {{1}}
|
||||
|
||||
# \x61 is the ASCII code for 'a', json_extract needs an exact match though
|
||||
do_execsql_test json_extract_with_escaping {
|
||||
SELECT json_extract('{"\x61": 1}', '$.a')
|
||||
} {{}}
|
||||
|
||||
# TODO: fix me
|
||||
#do_execsql_test json_extract_with_escaping_2 {
|
||||
# SELECT json_extract('{"\x61": 1}', '$.\x61')
|
||||
#} {{1}}
|
||||
|
||||
do_execsql_test json_extract_null_path {
|
||||
SELECT json_extract(1, null)
|
||||
} {{}}
|
||||
|
||||
do_execsql_test json_extract_multiple_null_paths {
|
||||
SELECT json_extract(1, null, null, null)
|
||||
} {{[null,null,null]}}
|
||||
|
||||
# TODO: fix me
|
||||
#do_execsql_test json_extract_quote {
|
||||
# SELECT json_extract('{"\"":1 }', '$.\"')
|
||||
#} {{1}}
|
||||
|
||||
# Overflows 2**32 is equivalent to 0
|
||||
do_execsql_test json_extract_overflow_int32_1 {
|
||||
SELECT json_extract('[1,2,3]', '$[4294967296]')
|
||||
} {{1}}
|
||||
|
||||
# Overflows 2**32 + 1 is equivalent to 1
|
||||
do_execsql_test json_extract_overflow_int32_2 {
|
||||
SELECT json_extract('[1,2,3]', '$[4294967297]')
|
||||
} {{2}}
|
||||
|
||||
# Overflows -2**32 - 1 is equivalent to -1
|
||||
do_execsql_test json_extract_overflow_int32_3 {
|
||||
SELECT json_extract('[1,2,3]', '$[#-4294967297]')
|
||||
} {{3}}
|
||||
|
||||
# Overflows -2**32 - 2 is equivalent to -2
|
||||
do_execsql_test json_extract_overflow_int32_3 {
|
||||
SELECT json_extract('[1,2,3]', '$[#-4294967298]')
|
||||
} {{2}}
|
||||
|
||||
# pow(2,63) + 1 == 9223372036854775808
|
||||
do_execsql_test json_extract_overflow_int64 {
|
||||
SELECT json_extract('[1,2,3]', '$[9223372036854775808]');
|
||||
} {{1}}
|
||||
|
||||
# TODO: fix me?
|
||||
# pow(2, 127) + 1 == 170141183460469231731687303715884105729
|
||||
#do_execsql_test json_extract_overflow_int128 {
|
||||
# SELECT json_extract('[1, 2, 3]', '$[170141183460469231731687303715884105729]');
|
||||
#} {{2}}
|
||||
|
||||
do_execsql_test json_extract_blob {
|
||||
select json_extract(CAST('[1,2,3]' as BLOB), '$[1]')
|
||||
} {{2}}
|
Loading…
Add table
Add a link
Reference in a new issue