blob: 5fb9e85736a97d39a228be0b0b020a0852c3d5b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#pragma ident "%Z%%M% %I% %E% SMI"
# 2001 September 15
#
# 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 the ability to specify table and column names
# as quoted strings.
#
# $Id: quote.test,v 1.3 2002/05/21 13:43:04 drh Exp $
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 {
set r [catch {
execsql {CREATE TABLE '@abc' ( '#xyz' int, '!pqr' text );}
} msg]
lappend r $msg
} {0 {}}
# Insert, update and query the table.
#
do_test quote-1.1 {
set r [catch {
execsql {INSERT INTO '@abc' VALUES(5,'hello')}
} msg]
lappend r $msg
} {0 {}}
do_test quote-1.2 {
set r [catch {
execsql {SELECT * FROM '@abc'}
} msg ]
lappend r $msg
} {0 {5 hello}}
do_test quote-1.3 {
set r [catch {
execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'}
} msg ]
lappend r $msg
} {0 {hello 10}}
do_test quote-1.3.1 {
catchsql {
SELECT '!pqr', '#xyz'+5 FROM '@abc'
}
} {0 {!pqr 5}}
do_test quote-1.3.2 {
catchsql {
SELECT "!pqr", "#xyz"+5 FROM '@abc'
}
} {0 {hello 10}}
do_test quote-1.3 {
set r [catch {
execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'}
} msg ]
lappend r $msg
} {0 {hello 10}}
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
|