mirror of
https://github.com/tursodatabase/libsql.git
synced 2024-12-15 03:59:46 +00:00
9ed72eb5ae
This merges the version-3.45.1 tag from upstream SQLite git repository to libSQL with the following conflicts resolved: Conflicts: README.md ext/jni/src/org/sqlite/jni/capi/ConfigSqllogCallback.java libsql-sqlite3/configure libsql-sqlite3/doc/jsonb.md libsql-sqlite3/ext/fts5/test/fts5faultH.test libsql-sqlite3/ext/fts5/test/fts5origintext.test libsql-sqlite3/ext/fts5/test/fts5origintext2.test libsql-sqlite3/ext/fts5/test/fts5origintext3.test libsql-sqlite3/ext/fts5/test/fts5origintext4.test libsql-sqlite3/ext/fts5/test/fts5origintext5.test libsql-sqlite3/ext/fts5/test/fts5secure8.test libsql-sqlite3/ext/fts5/test/fts5tokenizer2.test libsql-sqlite3/ext/fts5/test/fts5trigram2.test libsql-sqlite3/ext/jni/src/org/sqlite/jni/annotation/Experimental.java libsql-sqlite3/ext/jni/src/org/sqlite/jni/capi/ConfigSqlLogCallback.java libsql-sqlite3/ext/jni/src/org/sqlite/jni/capi/ConfigSqllogCallback.java libsql-sqlite3/ext/jni/src/org/sqlite/jni/wrapper1/WindowFunction.java libsql-sqlite3/ext/wasm/GNUmakefile libsql-sqlite3/ext/wasm/batch-runner-sahpool.html libsql-sqlite3/ext/wasm/batch-runner-sahpool.js libsql-sqlite3/src/pager.c libsql-sqlite3/src/shell.c.in libsql-sqlite3/src/sqliteInt.h libsql-sqlite3/src/wal.c libsql-sqlite3/test/fts3integrity.test libsql-sqlite3/test/json/jsonb-q1.txt libsql-sqlite3/test/json106.test libsql-sqlite3/test/json107.test libsql-sqlite3/test/jsonb01.test libsql-sqlite3/test/mmapcorrupt.test libsql-sqlite3/test/releasetest_data.tcl libsql-sqlite3/test/shell9.test libsql-sqlite3/test/wapp.tcl libsql-sqlite3/test/wapptest.tcl
87 lines
2.5 KiB
Plaintext
87 lines
2.5 KiB
Plaintext
# 2024-01-23
|
|
#
|
|
# The author disclaims copyright to this source code. In place of
|
|
# a legal notice, here is a blessing:
|
|
#
|
|
# May you do good and not evil.
|
|
# May you find forgiveness for yourself and forgive others.
|
|
# May you share freely, never taking more than you give.
|
|
#
|
|
#***********************************************************************
|
|
#
|
|
# Legacy JSON bug: If the input is a BLOB that when cast into TEXT looks
|
|
# like valid JSON, then treat it as valid JSON.
|
|
#
|
|
# The original intent of the JSON functions was to raise an error on any
|
|
# BLOB input. That intent was clearly documented, but the code failed to
|
|
# to implement it. Subsequently, many applications began to depend on the
|
|
# incorrect behavior, especially apps that used readfile() to read JSON
|
|
# content, since readfile() returns a BLOB. So we need to support the
|
|
# bug moving forward.
|
|
#
|
|
# The tests in this fail verify that the original buggy behavior is
|
|
# preserved.
|
|
#
|
|
|
|
set testdir [file dirname $argv0]
|
|
source $testdir/tester.tcl
|
|
set testprefix json107
|
|
|
|
if {[db one {PRAGMA encoding}]!="UTF-8"} {
|
|
# These tests only work for a UTF-8 encoding.
|
|
finish_test
|
|
return
|
|
}
|
|
|
|
do_execsql_test 1.1 {
|
|
SELECT json_valid( CAST('{"a":1}' AS BLOB) );
|
|
} 1
|
|
do_execsql_test 1.1.1 {
|
|
SELECT json_valid( CAST('{"a":1}' AS BLOB), 1);
|
|
} 1
|
|
do_execsql_test 1.1.2 {
|
|
SELECT json_valid( CAST('{"a":1}' AS BLOB), 2);
|
|
} 1
|
|
do_execsql_test 1.1.4 {
|
|
SELECT json_valid( CAST('{"a":1}' AS BLOB), 4);
|
|
} 0
|
|
do_execsql_test 1.1.8 {
|
|
SELECT json_valid( CAST('{"a":1}' AS BLOB), 8);
|
|
} 0
|
|
|
|
do_execsql_test 1.2.1 {
|
|
SELECT CAST('{"a":123}' AS blob) -> 'a';
|
|
} 123
|
|
do_execsql_test 1.2.2 {
|
|
SELECT CAST('{"a":123}' AS blob) ->> 'a';
|
|
} 123
|
|
do_execsql_test 1.2.3 {
|
|
SELECT json_extract(CAST('{"a":123}' AS blob), '$.a');
|
|
} 123
|
|
do_execsql_test 1.3 {
|
|
SELECT json_insert(CAST('{"a":123}' AS blob),'$.b',456);
|
|
} {{{"a":123,"b":456}}}
|
|
do_execsql_test 1.4 {
|
|
SELECT json_remove(CAST('{"a":123,"b":456}' AS blob),'$.a');
|
|
} {{{"b":456}}}
|
|
do_execsql_test 1.5 {
|
|
SELECT json_set(CAST('{"a":123,"b":456}' AS blob),'$.a',789);
|
|
} {{{"a":789,"b":456}}}
|
|
do_execsql_test 1.6 {
|
|
SELECT json_replace(CAST('{"a":123,"b":456}' AS blob),'$.a',789);
|
|
} {{{"a":789,"b":456}}}
|
|
do_execsql_test 1.7 {
|
|
SELECT json_type(CAST('{"a":123,"b":456}' AS blob));
|
|
} object
|
|
do_execsql_test 1.8 {
|
|
SELECT json(CAST('{"a":123,"b":456}' AS blob));
|
|
} {{{"a":123,"b":456}}}
|
|
|
|
ifcapable vtab {
|
|
do_execsql_test 2.1 {
|
|
SELECT key, value FROM json_tree( CAST('{"a":123,"b":456}' AS blob) )
|
|
WHERE atom;
|
|
} {a 123 b 456}
|
|
}
|
|
finish_test
|