xref: /sqlite-3.40.0/test/quote.test (revision b19a2bc6)
1# 2001 September 15
2#
3# The author disclaims copyright to this source code.  In place of
4# a legal notice, here is a blessing:
5#
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.
9#
10#***********************************************************************
11# This file implements regression tests for SQLite library.  The
12# focus of this file is the ability to specify table and column names
13# as quoted strings.
14#
15# $Id: quote.test,v 1.2 2001/09/16 00:13:28 drh Exp $
16
17set testdir [file dirname $argv0]
18source $testdir/tester.tcl
19
20# Create a table with a strange name and with strange column names.
21#
22do_test quote-1.0 {
23  set r [catch {
24    execsql {CREATE TABLE '@abc' ( '#xyz' int, '!pqr' text );}
25  } msg]
26  lappend r $msg
27} {0 {}}
28
29# Insert, update and query the table.
30#
31do_test quote-1.1 {
32  set r [catch {
33    execsql {INSERT INTO '@abc' VALUES(5,'hello')}
34  } msg]
35  lappend r $msg
36} {0 {}}
37do_test quote-1.2 {
38  set r [catch {
39    execsql {SELECT * FROM '@abc'}
40  } msg ]
41  lappend r $msg
42} {0 {5 hello}}
43do_test quote-1.3 {
44  set r [catch {
45    execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'}
46  } msg ]
47  lappend r $msg
48} {0 {hello 10}}
49do_test quote-1.4 {
50  set r [catch {
51    execsql {UPDATE '@abc' SET '#xyz'=11}
52  } msg ]
53  lappend r $msg
54} {0 {}}
55do_test quote-1.5 {
56  set r [catch {
57    execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'}
58  } msg ]
59  lappend r $msg
60} {0 {hello 16}}
61
62# Drop the table with the strange name.
63#
64do_test quote-1.6 {
65  set r [catch {
66    execsql {DROP TABLE '@abc'}
67  } msg ]
68  lappend r $msg
69} {0 {}}
70
71
72finish_test
73