2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A# 2001 September 15
2N/A#
2N/A# The author disclaims copyright to this source code. In place of
2N/A# a legal notice, here is a blessing:
2N/A#
2N/A# May you do good and not evil.
2N/A# May you find forgiveness for yourself and forgive others.
2N/A# May you share freely, never taking more than you give.
2N/A#
2N/A#***********************************************************************
2N/A# This file implements regression tests for SQLite library. The
2N/A# focus of this file is the ability to specify table and column names
2N/A# as quoted strings.
2N/A#
2N/A# $Id: quote.test,v 1.3 2002/05/21 13:43:04 drh Exp $
2N/A
2N/Aset testdir [file dirname $argv0]
2N/Asource $testdir/tester.tcl
2N/A
2N/A# Create a table with a strange name and with strange column names.
2N/A#
2N/Ado_test quote-1.0 {
2N/A set r [catch {
2N/A execsql {CREATE TABLE '@abc' ( '#xyz' int, '!pqr' text );}
2N/A } msg]
2N/A lappend r $msg
2N/A} {0 {}}
2N/A
2N/A# Insert, update and query the table.
2N/A#
2N/Ado_test quote-1.1 {
2N/A set r [catch {
2N/A execsql {INSERT INTO '@abc' VALUES(5,'hello')}
2N/A } msg]
2N/A lappend r $msg
2N/A} {0 {}}
2N/Ado_test quote-1.2 {
2N/A set r [catch {
2N/A execsql {SELECT * FROM '@abc'}
2N/A } msg ]
2N/A lappend r $msg
2N/A} {0 {5 hello}}
2N/Ado_test quote-1.3 {
2N/A set r [catch {
2N/A execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'}
2N/A } msg ]
2N/A lappend r $msg
2N/A} {0 {hello 10}}
2N/Ado_test quote-1.3.1 {
2N/A catchsql {
2N/A SELECT '!pqr', '#xyz'+5 FROM '@abc'
2N/A }
2N/A} {0 {!pqr 5}}
2N/Ado_test quote-1.3.2 {
2N/A catchsql {
2N/A SELECT "!pqr", "#xyz"+5 FROM '@abc'
2N/A }
2N/A} {0 {hello 10}}
2N/Ado_test quote-1.3 {
2N/A set r [catch {
2N/A execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'}
2N/A } msg ]
2N/A lappend r $msg
2N/A} {0 {hello 10}}
2N/Ado_test quote-1.4 {
2N/A set r [catch {
2N/A execsql {UPDATE '@abc' SET '#xyz'=11}
2N/A } msg ]
2N/A lappend r $msg
2N/A} {0 {}}
2N/Ado_test quote-1.5 {
2N/A set r [catch {
2N/A execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'}
2N/A } msg ]
2N/A lappend r $msg
2N/A} {0 {hello 16}}
2N/A
2N/A# Drop the table with the strange name.
2N/A#
2N/Ado_test quote-1.6 {
2N/A set r [catch {
2N/A execsql {DROP TABLE '@abc'}
2N/A } msg ]
2N/A lappend r $msg
2N/A} {0 {}}
2N/A
2N/A
2N/Afinish_test