Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/test/json108.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / test / json108.test` 122 lines ยท 3021 bytes Raw Blame History 1 # 2024-03-06 2 # 3 # The author disclaims copyright to this source code. In place of 4 # a legal notice, here is a blessing: 5 # 6 # May you do good and not evil. 7 # May you find forgiveness for yourself and forgive others. 8 # May you share freely, never taking more than you give. 9 # 10 #*********************************************************************** 11 # Invariant tests for JSON built around the randomjson extension 12 # 13 14 set testdir [file dirname $argv0] 15 source $testdir/tester.tcl 16 set testprefix json108 17 18 # These tests require virtual table "json_tree" to run. 19 ifcapable !vtab { finish_test ; return } 20 21 load_static_extension db randomjson 22 db eval { 23 CREATE TEMP TABLE t1(j0,j5); 24 WITH RECURSIVE c(n) AS (VALUES(0) UNION ALL SELECT n+1 FROM c WHERE n<9) 25 INSERT INTO t1 SELECT random_json(n), random_json5(n) FROM c; 26 } 27 28 do_execsql_test 1.1 { 29 SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,NULL)); 30 } 10 31 do_execsql_test 1.2 { 32 SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,NULL)); 33 } 10 34 do_execsql_test 1.3 { 35 SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,'')); 36 } 10 37 do_execsql_test 1.4 { 38 SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,char(9))); 39 } 10 40 do_execsql_test 1.5 { 41 SELECT count(*) FROM t1 WHERE json(j0)==json(json_pretty(j0,'/*hello*/')); 42 } 10 43 44 #------------------------------------------------------------------------- 45 46 do_execsql_test 2.0 { 47 CREATE TABLE obj(x); 48 INSERT INTO obj VALUES('{name:"value"}'); 49 50 CREATE TABLE one(y); 51 INSERT INTO one VALUES(1); 52 53 CREATE TABLE zero(z); 54 } 55 56 57 do_execsql_test 2.1 { 58 SELECT key, value FROM json_tree(obj.x) JOIN obj; 59 } { 60 {} {{"name":"value"}} name value 61 } 62 63 do_catchsql_test 2.2 { 64 SELECT key, value FROM json_tree(obj.x) LEFT JOIN obj; 65 } { 66 1 {table-function argument references tables to its right} 67 } 68 69 do_catchsql_test 2.3 { 70 SELECT key, value FROM json_tree(obj.x) LEFT JOIN obj WHERE obj.x!=''; 71 } { 72 1 {table-function argument references tables to its right} 73 } 74 75 do_catchsql_test 2.4 { 76 SELECT key, value FROM json_tree(obj.x), one LEFT JOIN obj WHERE obj.x!=''; 77 } { 78 1 {table-function argument references tables to its right} 79 } 80 81 do_execsql_test 2.5 { 82 SELECT key, value FROM json_tree(obj.x), obj LEFT JOIN one; 83 } { 84 {} {{"name":"value"}} name value 85 } 86 87 do_execsql_test 2.6 { 88 SELECT key, value FROM obj, json_tree(obj.x) LEFT JOIN one; 89 } { 90 {} {{"name":"value"}} name value 91 } 92 93 do_execsql_test 2.7 { 94 SELECT key, value FROM one LEFT JOIN json_tree(obj.x), obj; 95 } { 96 {} {{"name":"value"}} name value 97 } 98 99 do_execsql_test 2.8 { 100 SELECT key, value FROM one LEFT JOIN obj, json_tree(obj.x); 101 } { 102 {} {{"name":"value"}} name value 103 } 104 105 do_execsql_test 2.9 { 106 SELECT key, value FROM zero LEFT JOIN obj, json_tree(obj.x); 107 } { 108 } 109 110 do_execsql_test 2.10 { 111 SELECT key, value FROM obj LEFT JOIN json_tree(obj.x); 112 } { 113 {} {{"name":"value"}} name value 114 } 115 116 do_execsql_test 2.11 { 117 SELECT key, value FROM obj LEFT JOIN zero, json_tree(obj.x); 118 } { 119 {} {{"name":"value"}} name value 120 } 121 122 finish_test