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/json109.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 / json109.test` 72 lines ยท 2291 bytes Raw Blame History 1 # 2026-01-17 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 # 12 # Test cases for json_array_insert(). 13 # 14 15 set testdir [file dirname $argv0] 16 source $testdir/tester.tcl 17 set testprefix json109 18 19 do_execsql_test 1.1 { 20 SELECT json_array_insert('[1,2,3]','$[0]',999,'$[0]',888); 21 } {{[888,999,1,2,3]}} 22 do_execsql_test 1.2 { 23 SELECT json_array_insert('[1,2,3]','$[0]',999,'$[#]',888); 24 } {{[999,1,2,3,888]}} 25 do_execsql_test 1.3 { 26 SELECT json_array_insert('[1,2,3]','$[1]',888); 27 } {{[1,888,2,3]}} 28 do_execsql_test 1.4 { 29 SELECT json_array_insert('[1,2,3]','$[2]',888); 30 } {{[1,2,888,3]}} 31 do_execsql_test 1.5 { 32 SELECT json_array_insert('[1,2,3]','$[3]',888); 33 } {{[1,2,3,888]}} 34 do_execsql_test 1.6 { 35 SELECT json_array_insert('[1,2,3]','$[#-1]',888); 36 } {{[1,2,888,3]}} 37 do_execsql_test 1.7 { 38 SELECT json_array_insert('[1,2,3]','$[#-2]',888); 39 } {{[1,888,2,3]}} 40 do_execsql_test 1.8 { 41 SELECT json_array_insert('[1,2,3]','$[#-3]',888); 42 } {{[888,1,2,3]}} 43 do_execsql_test 1.9 { 44 SELECT json_array_insert('[1,2,3]','$[#-4]',888); 45 } {{[1,2,3]}} 46 47 do_catchsql_test 2.1 { 48 SELECT json_array_insert('{a:[1,2,3]}','$.a',888); 49 } {1 {not an array element: '$.a'}} 50 do_catchsql_test 2.2 { 51 SELECT json_array_insert('{a:[1,2,3]}','$.b',888); 52 } {1 {not an array element: '$.b'}} 53 do_catchsql_test 2.3 { 54 SELECT json_array_insert('{a:[1,2,3]}','$.b[0]',888); 55 } {0 {{{"a":[1,2,3],"b":[888]}}}} 56 do_catchsql_test 2.4 { 57 SELECT json_array_insert('{a:[1,2,3]}','$.b.c.d[0]',888); 58 } {0 {{{"a":[1,2,3],"b":{"c":{"d":[888]}}}}}} 59 do_catchsql_test 2.5 { 60 SELECT json_array_insert('{a:[1,2,3]}','$.b.c.d[0',888); 61 } {1 {not an array element: '$.b.c.d[0'}} 62 do_catchsql_test 2.6 { 63 SELECT json_array_insert('{a:[1,2,3]}','$.b.c.d',888); 64 } {1 {not an array element: '$.b.c.d'}} 65 do_catchsql_test 2.7 { 66 SELECT json_array_insert('{a:[1,2,3]}','$[0]',888); 67 } {0 {{{"a":[1,2,3]}}}} 68 do_catchsql_test 2.8 { 69 SELECT json_array_insert('{a:[1,2,3]}','$.b[0]',888,'$.a[1]','999','$.c',0); 70 } {1 {not an array element: '$.c'}} 71 72 finish_test