mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-22 02:34:20 +01:00
test: add TCL tests for json_object
This commit is contained in:
@@ -506,3 +506,41 @@ do_execsql_test json_error_position_null {
|
||||
do_execsql_test json_error_position_complex {
|
||||
SELECT json_error_position('{a:null,{"h":[1,[1,2,3]],"j":"abc"}:true}');
|
||||
} {{9}}
|
||||
|
||||
do_execsql_test json_object_simple {
|
||||
SELECT json_object('key', 'value');
|
||||
} {{{"key":"value"}}}
|
||||
|
||||
do_execsql_test json_object_nested {
|
||||
SELECT json_object('grandparent',json_object('parent', json_object('child', 'value')));
|
||||
} {{{"grandparent":{"parent":{"child":"value"}}}}}
|
||||
|
||||
do_execsql_test json_object_quoted_json {
|
||||
SELECT json_object('parent', '{"child":"value"}');
|
||||
} {{{"parent":"{\"child\":\"value\"}"}}}
|
||||
|
||||
do_execsql_test json_object_unquoted_json {
|
||||
SELECT json_object('parent', json('{"child":"value"}'));
|
||||
} {{{"parent":{"child":"value"}}}}
|
||||
|
||||
do_execsql_test json_object_multiple_values {
|
||||
SELECT json_object('text', 'value', 'json', json_object('key', 'value'), 'int', 1, 'float', 1.5, 'null', null);
|
||||
} {{{"text":"value","json":{"key":"value"},"int":1,"float":1.5,"null":null}}}
|
||||
|
||||
do_execsql_test json_object_empty {
|
||||
SELECT json_object();
|
||||
} {{{}}}
|
||||
|
||||
do_execsql_test json_object_json_array {
|
||||
SELECT json_object('ex',json('[52,3]'));
|
||||
} {{{"ex":[52,3]}}}
|
||||
|
||||
do_execsql_test json_from_json_object {
|
||||
SELECT json(json_object('key','value'));
|
||||
} {{{"key":"value"}}}
|
||||
|
||||
# FIXME: this behaviour differs from sqlite. Although, sqlite docs states
|
||||
# that this could change in a "future enhancement" (https://www.sqlite.org/json1.html#jobj)
|
||||
#do_execsql_test json_object_duplicated_keys {
|
||||
# SELECT json_object('key', 'value', 'key', 'value2');
|
||||
#} {{{"key":"value2"}}}
|
||||
|
||||
Reference in New Issue
Block a user