mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-10 11:44:22 +01:00
Merge 'Implement json_array' from Kacper Madej
Implements [json_array](https://sqlite.org/json1.html#jarray). As a side quest, this PR also fixes an issue with the `CHAR` function which didn't work properly if the parameters were non-leaf AST nodes. The PR is quite big, because as I mentioned in https://github.com/tursod atabase/limbo/issues/127#issuecomment-2541307979 we had to modify `OwnedValue::Text` to support a `subtype` parameter, which is what SQLite does. Closes #504
This commit is contained in:
28
testing/json.test
Normal file → Executable file
28
testing/json.test
Normal file → Executable file
@@ -55,3 +55,31 @@ do_execsql_test json5-multi-comment {
|
||||
SELECT json(' /* abc */ { /*def*/ aaa /* xyz */ : // to the end of line
|
||||
123 /* xyz */ , /* 123 */ }')
|
||||
} {{{"aaa":123}}}
|
||||
|
||||
do_execsql_test json_array_str {
|
||||
SELECT json_array('a')
|
||||
} {{["a"]}}
|
||||
|
||||
do_execsql_test json_array_numbers {
|
||||
SELECT json_array(1, 1.5)
|
||||
} {{[1,1.5]}}
|
||||
|
||||
do_execsql_test json_array_numbers_2 {
|
||||
SELECT json_array(1., +2., -2.)
|
||||
} {{[1.0,2.0,-2.0]}}
|
||||
|
||||
do_execsql_test json_array_null {
|
||||
SELECT json_array(null)
|
||||
} {{[null]}}
|
||||
|
||||
do_execsql_test json_array_not_json {
|
||||
SELECT json_array('{"a":1}')
|
||||
} {{["{\"a\":1}"]}}
|
||||
|
||||
do_execsql_test json_array_json {
|
||||
SELECT json_array(json('{"a":1}'))
|
||||
} {{[{"a":1}]}}
|
||||
|
||||
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]"]}}
|
||||
|
||||
@@ -39,6 +39,10 @@ do_execsql_test char {
|
||||
select char(108, 105)
|
||||
} {li}
|
||||
|
||||
do_execsql_test char-nested {
|
||||
select char(106 + 2, 105)
|
||||
} {li}
|
||||
|
||||
do_execsql_test char-empty {
|
||||
select char()
|
||||
} {}
|
||||
|
||||
Reference in New Issue
Block a user