2001-09-16 04:13:26 +04:00
|
|
|
# 2001 September 15
|
2001-07-23 18:33:02 +04:00
|
|
|
#
|
2001-09-16 04:13:26 +04:00
|
|
|
# The author disclaims copyright to this source code. In place of
|
|
|
|
# a legal notice, here is a blessing:
|
2001-07-23 18:33:02 +04:00
|
|
|
#
|
2001-09-16 04:13:26 +04:00
|
|
|
# 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.
|
2001-07-23 18:33:02 +04:00
|
|
|
#
|
|
|
|
#***********************************************************************
|
|
|
|
# This file implements regression tests for SQLite library. The
|
|
|
|
# focus of this file is the ability to specify table and column names
|
|
|
|
# as quoted strings.
|
|
|
|
#
|
2007-04-25 15:32:30 +04:00
|
|
|
# $Id: quote.test,v 1.7 2007/04/25 11:32:30 drh Exp $
|
2001-07-23 18:33:02 +04:00
|
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $testdir/tester.tcl
|
|
|
|
|
|
|
|
# Create a table with a strange name and with strange column names.
|
|
|
|
#
|
|
|
|
do_test quote-1.0 {
|
2005-08-13 22:15:42 +04:00
|
|
|
catchsql {CREATE TABLE '@abc' ( '#xyz' int, '!pqr' text );}
|
2001-07-23 18:33:02 +04:00
|
|
|
} {0 {}}
|
|
|
|
|
|
|
|
# Insert, update and query the table.
|
|
|
|
#
|
|
|
|
do_test quote-1.1 {
|
2005-08-13 22:15:42 +04:00
|
|
|
catchsql {INSERT INTO '@abc' VALUES(5,'hello')}
|
2001-07-23 18:33:02 +04:00
|
|
|
} {0 {}}
|
2005-08-13 22:15:42 +04:00
|
|
|
do_test quote-1.2.1 {
|
|
|
|
catchsql {SELECT * FROM '@abc'}
|
|
|
|
} {0 {5 hello}}
|
|
|
|
do_test quote-1.2.2 {
|
|
|
|
catchsql {SELECT * FROM [@abc]} ;# SqlServer compatibility
|
|
|
|
} {0 {5 hello}}
|
|
|
|
do_test quote-1.2.3 {
|
|
|
|
catchsql {SELECT * FROM `@abc`} ;# MySQL compatibility
|
2001-07-23 18:33:02 +04:00
|
|
|
} {0 {5 hello}}
|
|
|
|
do_test quote-1.3 {
|
2005-08-13 22:15:42 +04:00
|
|
|
catchsql {
|
|
|
|
SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'
|
|
|
|
}
|
2001-07-23 18:33:02 +04:00
|
|
|
} {0 {hello 10}}
|
2002-05-21 17:43:04 +04:00
|
|
|
do_test quote-1.3.1 {
|
|
|
|
catchsql {
|
|
|
|
SELECT '!pqr', '#xyz'+5 FROM '@abc'
|
|
|
|
}
|
2005-11-01 18:48:24 +03:00
|
|
|
} {0 {!pqr 5}}
|
2002-05-21 17:43:04 +04:00
|
|
|
do_test quote-1.3.2 {
|
|
|
|
catchsql {
|
|
|
|
SELECT "!pqr", "#xyz"+5 FROM '@abc'
|
|
|
|
}
|
|
|
|
} {0 {hello 10}}
|
2005-08-13 22:15:42 +04:00
|
|
|
do_test quote-1.3.3 {
|
|
|
|
catchsql {
|
|
|
|
SELECT [!pqr], `#xyz`+5 FROM '@abc'
|
|
|
|
}
|
|
|
|
} {0 {hello 10}}
|
2007-04-25 15:32:30 +04:00
|
|
|
do_test quote-1.3.4 {
|
2002-05-21 17:43:04 +04:00
|
|
|
set r [catch {
|
|
|
|
execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'}
|
|
|
|
} msg ]
|
|
|
|
lappend r $msg
|
|
|
|
} {0 {hello 10}}
|
2001-07-23 18:33:02 +04:00
|
|
|
do_test quote-1.4 {
|
|
|
|
set r [catch {
|
|
|
|
execsql {UPDATE '@abc' SET '#xyz'=11}
|
|
|
|
} msg ]
|
|
|
|
lappend r $msg
|
|
|
|
} {0 {}}
|
|
|
|
do_test quote-1.5 {
|
|
|
|
set r [catch {
|
|
|
|
execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'}
|
|
|
|
} msg ]
|
|
|
|
lappend r $msg
|
|
|
|
} {0 {hello 16}}
|
|
|
|
|
|
|
|
# Drop the table with the strange name.
|
|
|
|
#
|
|
|
|
do_test quote-1.6 {
|
|
|
|
set r [catch {
|
|
|
|
execsql {DROP TABLE '@abc'}
|
|
|
|
} msg ]
|
|
|
|
lappend r $msg
|
|
|
|
} {0 {}}
|
|
|
|
|
|
|
|
|
|
|
|
finish_test
|