os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/quote.test
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/quote.test	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,89 @@
     1.4 +# 2001 September 15
     1.5 +#
     1.6 +# The author disclaims copyright to this source code.  In place of
     1.7 +# a legal notice, here is a blessing:
     1.8 +#
     1.9 +#    May you do good and not evil.
    1.10 +#    May you find forgiveness for yourself and forgive others.
    1.11 +#    May you share freely, never taking more than you give.
    1.12 +#
    1.13 +#***********************************************************************
    1.14 +# This file implements regression tests for SQLite library.  The
    1.15 +# focus of this file is the ability to specify table and column names
    1.16 +# as quoted strings.
    1.17 +#
    1.18 +# $Id: quote.test,v 1.7 2007/04/25 11:32:30 drh Exp $
    1.19 +
    1.20 +set testdir [file dirname $argv0]
    1.21 +source $testdir/tester.tcl
    1.22 +
    1.23 +# Create a table with a strange name and with strange column names.
    1.24 +#
    1.25 +do_test quote-1.0 {
    1.26 +  catchsql {CREATE TABLE '@abc' ( '#xyz' int, '!pqr' text );}
    1.27 +} {0 {}}
    1.28 +
    1.29 +# Insert, update and query the table.
    1.30 +#
    1.31 +do_test quote-1.1 {
    1.32 +  catchsql {INSERT INTO '@abc' VALUES(5,'hello')}
    1.33 +} {0 {}}
    1.34 +do_test quote-1.2.1 {
    1.35 +  catchsql {SELECT * FROM '@abc'}
    1.36 +} {0 {5 hello}}
    1.37 +do_test quote-1.2.2 {
    1.38 +  catchsql {SELECT * FROM [@abc]}  ;# SqlServer compatibility
    1.39 +} {0 {5 hello}}
    1.40 +do_test quote-1.2.3 {
    1.41 +  catchsql {SELECT * FROM `@abc`}  ;# MySQL compatibility
    1.42 +} {0 {5 hello}}
    1.43 +do_test quote-1.3 {
    1.44 +  catchsql {
    1.45 +    SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'
    1.46 +  }
    1.47 +} {0 {hello 10}}
    1.48 +do_test quote-1.3.1 {
    1.49 +  catchsql {
    1.50 +    SELECT '!pqr', '#xyz'+5 FROM '@abc'
    1.51 +  }
    1.52 +} {0 {!pqr 5}}
    1.53 +do_test quote-1.3.2 {
    1.54 +  catchsql {
    1.55 +    SELECT "!pqr", "#xyz"+5 FROM '@abc'
    1.56 +  }
    1.57 +} {0 {hello 10}}
    1.58 +do_test quote-1.3.3 {
    1.59 +  catchsql {
    1.60 +    SELECT [!pqr], `#xyz`+5 FROM '@abc'
    1.61 +  }
    1.62 +} {0 {hello 10}}
    1.63 +do_test quote-1.3.4 {
    1.64 +  set r [catch {
    1.65 +    execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'}
    1.66 +  } msg ]
    1.67 +  lappend r $msg
    1.68 +} {0 {hello 10}}
    1.69 +do_test quote-1.4 {
    1.70 +  set r [catch {
    1.71 +    execsql {UPDATE '@abc' SET '#xyz'=11}
    1.72 +  } msg ]
    1.73 +  lappend r $msg
    1.74 +} {0 {}}
    1.75 +do_test quote-1.5 {
    1.76 +  set r [catch {
    1.77 +    execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'}
    1.78 +  } msg ]
    1.79 +  lappend r $msg
    1.80 +} {0 {hello 16}}
    1.81 +
    1.82 +# Drop the table with the strange name.
    1.83 +#
    1.84 +do_test quote-1.6 {
    1.85 +  set r [catch {
    1.86 +    execsql {DROP TABLE '@abc'}
    1.87 +  } msg ]
    1.88 +  lappend r $msg
    1.89 +} {0 {}}
    1.90 + 
    1.91 +
    1.92 +finish_test