3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
12 # Tests for the sqlite3_normalize() extension function.
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
17 set testprefix normalize
19 foreach {tnum sql norm} {
21 {SELECT * FROM t1 WHERE a IN (1) AND b=51.42}
22 {select*from t1 where a in(?,?,?)and b=?;}
25 {SELECT a, b+15, c FROM t1 WHERE d NOT IN (SELECT x FROM t2);}
26 {select a,b+?,c from t1 where d not in(select x from t2);}
29 { SELECT NULL, b FROM t1 -- comment text
30 WHERE d IN (WITH t(a) AS (VALUES(5)) /* CTE */
34 {select?,b from t1 where d in(with t(a)as(values(?))select a from t)or e=?;}
38 -- another comment line
39 SELECT NULL /* comment */ , b FROM t1 -- comment text
40 WHERE d IN (WITH t(a) AS (VALUES(5)) /* CTE */
44 {select?,b from t1 where d in(with t(a)as(values(?))select a from t)or e=?;}
47 {/* Query containing parameters */
48 SELECT x,$::abc(15),y,@abc,z,?99,w FROM t1 /* Trailing comment */}
49 {select x,?,y,?,z,?,w from t1;}
52 {/* Long list on the RHS of IN */
53 SELECT 15 IN (1,2,3,(SELECT * FROM t1),'xyz',x'abcd',22*(x+5),null);}
57 {SELECT x'abc'; -- illegal token}
61 {SELECT a,NULL,b FROM t1 WHERE c IS NOT NULL or D is null or e=5}
62 {select a,?,b from t1 where c is not null or d is null or e=?;}
65 {/* IN list exactly 5 bytes long */
66 SELECT * FROM t1 WHERE x IN (1,2,3);}
67 {select*from t1 where x in(?,?,?);}
69 do_test $tnum [list sqlite3_normalize $sql] $norm