Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Unified Diff: third_party/sqlite/sqlite-src-3170000/test/json103.test

Issue 2747283002: [sql] Import reference version of SQLite 3.17.. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/sqlite/sqlite-src-3170000/test/json103.test
diff --git a/third_party/sqlite/sqlite-src-3170000/test/json103.test b/third_party/sqlite/sqlite-src-3170000/test/json103.test
new file mode 100644
index 0000000000000000000000000000000000000000..d7d12e3378259c7b92bfc0a89504d97fd9b04e7a
--- /dev/null
+++ b/third_party/sqlite/sqlite-src-3170000/test/json103.test
@@ -0,0 +1,78 @@
+# 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}}}
+
+# ticket https://www.sqlite.org/src/info/f45ac567eaa9f93c 2016-01-30
+# Invalid JSON generated by json_group_array()
+#
+# The underlying problem is a failure to reset Mem.eSubtype
+#
+do_execsql_test json103-300 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES(1),('abc');
+ SELECT
+ json_group_array(x),
+ json_group_array(json_object('x',x))
+ FROM t1;
+} {{[1,"abc"]} {[{"x":1},{"x":"abc"}]}}
+
+finish_test
« no previous file with comments | « third_party/sqlite/sqlite-src-3170000/test/json102.test ('k') | third_party/sqlite/sqlite-src-3170000/test/keyword1.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698