diff options
author | drh <drh@noemail.net> | 2016-01-01 13:25:06 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2016-01-01 13:25:06 +0000 |
commit | 8de1d77c60af1fbac5cc7eb7eb84efa3e43a320b (patch) | |
tree | b2968afbe57bd3f1d1305f5a2241f575cca3b909 /test/json103.test | |
parent | 173b60999eb7b2fda450df311e286539fcd2b854 (diff) | |
parent | a660caf2f01c99ef48085c731e200b5a2fa575b5 (diff) | |
download | sqlite-8de1d77c60af1fbac5cc7eb7eb84efa3e43a320b.tar.gz sqlite-8de1d77c60af1fbac5cc7eb7eb84efa3e43a320b.zip |
Merge the latest enhancements from trunk.
FossilOrigin-Name: c0be246a740c8f33a7c07e1414688364dee56ece
Diffstat (limited to 'test/json103.test')
-rw-r--r-- | test/json103.test | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/test/json103.test b/test/json103.test new file mode 100644 index 000000000..0f0241e6f --- /dev/null +++ b/test/json103.test @@ -0,0 +1,65 @@ +# 2015-12-30 +# +# 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. +# +#*********************************************************************** +# This file implements tests for JSON aggregate SQL functions +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +ifcapable !json1 { + finish_test + return +} + +do_execsql_test json103-100 { + CREATE TABLE t1(a,b,c); + WITH RECURSIVE c(x) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<100) + INSERT INTO t1(a,b,c) SELECT x, x%3, printf('n%d',x) FROM c; + UPDATE t1 SET a='orange' WHERE rowid=39; + UPDATE t1 SET a=32.5 WHERE rowid=31; + UPDATE t1 SET a=x'303132' WHERE rowid=29; + UPDATE t1 SET a=NULL WHERE rowid=37; + SELECT json_group_array(a) FROM t1 WHERE a<0 AND typeof(a)!='blob'; +} {{[]}} +do_catchsql_test json103-101 { + SELECT json_group_array(a) FROM t1; +} {1 {JSON cannot hold BLOB values}} +do_execsql_test json103-110 { + SELECT json_group_array(a) FROM t1 + WHERE rowid BETWEEN 31 AND 39; +} {{[32.5,32,33,34,35,36,null,38,"orange"]}} +do_execsql_test json103-111 { + SELECT json_array_length(json_group_array(a)) FROM t1 + WHERE rowid BETWEEN 31 AND 39; +} {9} +do_execsql_test json103-120 { + SELECT b, json_group_array(a) FROM t1 WHERE rowid<10 GROUP BY b ORDER BY b; +} {0 {[3,6,9]} 1 {[1,4,7]} 2 {[2,5,8]}} + +do_execsql_test json103-200 { + SELECT json_group_object(c,a) FROM t1 WHERE a<0 AND typeof(a)!='blob'; +} {{{}}} +do_catchsql_test json103-201 { + SELECT json_group_object(c,a) FROM t1; +} {1 {JSON cannot hold BLOB values}} + +do_execsql_test json103-210 { + SELECT json_group_object(c,a) FROM t1 + WHERE rowid BETWEEN 31 AND 39 AND rowid%2==1; +} {{{"n31":32.5,"n33":33,"n35":35,"n37":null,"n39":"orange"}}} +do_execsql_test json103-220 { + SELECT b, json_group_object(c,a) FROM t1 + WHERE rowid<7 GROUP BY b ORDER BY b; +} {0 {{"n3":3,"n6":6}} 1 {{"n1":1,"n4":4}} 2 {{"n2":2,"n5":5}}} + + + +finish_test |