sqlite/test/view.test
drh ff78bd2f07 Bug fixes in the VIEW implementation. (CVS 396)
FossilOrigin-Name: 668ef6380eba256ef82477b63aef850249a619a0
2002-02-27 01:47:11 +00:00

76 lines
1.7 KiB
Plaintext

# 2002 February 26
#
# 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 regression tests for SQLite library. The
# focus of this file is testing VIEW statements.
#
# $Id: view.test,v 1.1 2002/02/27 01:47:12 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
do_test view-1.0 {
execsql {
CREATE TABLE t1(a,b,c);
INSERT INTO t1 VALUES(1,2,3);
INSERT INTO t1 VALUES(4,5,6);
INSERT INTO t1 VALUES(7,8,9);
SELECT * FROM t1;
}
} {1 2 3 4 5 6 7 8 9}
do_test view-1.1 {
execsql {
BEGIN;
CREATE VIEW v1 AS SELECT a,b FROM t1;
SELECT * FROM v1 ORDER BY a;
}
} {1 2 4 5 7 8}
do_test view-1.2 {
catchsql {
ROLLBACK;
SELECT * FROM v1 ORDER BY a;
}
} {1 {no such table: v1}}
do_test view-1.3 {
execsql {
CREATE VIEW v1 AS SELECT a,b FROM t1;
SELECT * FROM v1 ORDER BY a;
}
} {1 2 4 5 7 8}
do_test view-1.4 {
catchsql {
DROP VIEW v1;
SELECT * FROM v1 ORDER BY a;
}
} {1 {no such table: v1}}
do_test view-1.5 {
execsql {
CREATE VIEW v1 AS SELECT a,b FROM t1;
SELECT * FROM v1 ORDER BY a;
}
} {1 2 4 5 7 8}
do_test view-1.6 {
catchsql {
DROP TABLE t1;
SELECT * FROM v1 ORDER BY a;
}
} {1 {no such table: t1}}
do_test view-1.7 {
execsql {
CREATE TABLE t1(x,a,b,c);
INSERT INTO t1 VALUES(1,2,3,4);
INSERT INTO t1 VALUES(4,5,6,7);
INSERT INTO t1 VALUES(7,8,9,10);
SELECT * FROM v1 ORDER BY a;
}
} {2 3 5 6 8 9}
finish_test