Add a test for the fixes on this branch.
[sqlite.git] / test / view2.test
blobe5df1437fe2e566ace875ae37998247da4c84d47
1 # 2021 May 20
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 #***********************************************************************
11 # This file implements regression tests for SQLite library.  The
12 # focus of this file is testing VIEW statements.
14 # $Id: view.test,v 1.39 2008/12/14 14:45:21 danielk1977 Exp $
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
18 # Omit this entire file if the library is not configured with views enabled.
19 ifcapable !view {
20   finish_test
21   return
23 set testprefix view2
25 do_execsql_test 1.0 {
26   CREATE TABLE t1(x, y);
27   INSERT INTO t1 VALUES(1, 2);
28   CREATE VIEW v1 AS SELECT * FROM (
29     WITH x1 AS (SELECT y, x FROM t1)
30     SELECT * FROM x1
31   );
34 do_execsql_test 1.1 {
35   SELECT * FROM v1
36 } {2 1}
38 do_execsql_test 1.2 {
39   CREATE VIEW v3 AS SELECT * FROM main.t1;
40   WITH t1(a, b) AS ( SELECT 3, 4 ) SELECT * FROM v3;
41 } {1 2}
43 breakpoint
44 do_execsql_test 1.3 {
45   CREATE VIEW v2 AS SELECT * FROM t1;
46   WITH t1(a, b) AS ( SELECT 3, 4 ) SELECT * FROM v2;
47 } {1 2}
49 finish_test