mirror of
https://github.com/sqlite/sqlite.git
synced 2025-12-24 14:17:58 +03:00
Port the "DEFAULT CURRENT_TIME" etc. functionality from an earlier fork of sqlite. (CVS 2082)
FossilOrigin-Name: 0d27c8ff48f327ad82dd5b5b3b47b8d221f119b7
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing expressions.
|
||||
#
|
||||
# $Id: expr.test,v 1.36 2004/08/20 18:34:20 drh Exp $
|
||||
# $Id: expr.test,v 1.37 2004/11/09 12:44:39 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -474,5 +474,30 @@ test_expr2 expr-7.61 {GLOB('1?',a)} {10 11 12 13 14 15 16 17 18 19}
|
||||
test_expr2 expr-7.62 {GLOB('1*4',b)} {10 14}
|
||||
test_expr2 expr-7.63 {GLOB('*1[456]',b)} {4}
|
||||
|
||||
# Test the CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP expressions.
|
||||
#
|
||||
set sqlite_current_time [clock seconds]
|
||||
set date [clock format $sqlite_current_time -format %Y-%m-%d -gmt 1]
|
||||
set time [clock format $sqlite_current_time -format %H:%M:%S -gmt 1]
|
||||
do_test expr-8.1 {
|
||||
execsql {SELECT CURRENT_TIME==time('now');}
|
||||
} 1
|
||||
do_test expr-8.2 {
|
||||
execsql {SELECT CURRENT_TIME}
|
||||
} $time
|
||||
do_test expr-8.3 {
|
||||
execsql {SELECT CURRENT_DATE==date('now');}
|
||||
} 1
|
||||
do_test expr-8.4 {
|
||||
execsql {SELECT CURRENT_DATE}
|
||||
} $date
|
||||
do_test expr-8.5 {
|
||||
execsql {SELECT CURRENT_TIMESTAMP==datetime('now');}
|
||||
} 1
|
||||
do_test expr-8.6 {
|
||||
execsql {SELECT CURRENT_TIMESTAMP}
|
||||
} [list "$date $time"]
|
||||
set sqlite_current_time 0
|
||||
|
||||
finish_test
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the CREATE TABLE statement.
|
||||
#
|
||||
# $Id: table.test,v 1.30 2004/11/03 16:27:02 drh Exp $
|
||||
# $Id: table.test,v 1.31 2004/11/09 12:44:39 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -524,4 +524,36 @@ do_test table-12.2 {
|
||||
}
|
||||
} {{CREATE TABLE t8(b number(5,10),h,i integer,j BLOB)}}
|
||||
|
||||
# Test the ability to have default values of CURRENT_TIME, CURRENT_DATE
|
||||
# and CURRENT_TIMESTAMP.
|
||||
#
|
||||
do_test table-13.1 {
|
||||
execsql {
|
||||
CREATE TABLE tablet8(
|
||||
a integer primary key,
|
||||
tm text DEFAULT CURRENT_TIME,
|
||||
dt text DEFAULT CURRENT_DATE,
|
||||
dttm text DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
SELECT * FROM tablet8;
|
||||
}
|
||||
} {}
|
||||
set i 0
|
||||
foreach {date time} {
|
||||
1976-07-04 12:00:00
|
||||
1994-04-16 14:00:00
|
||||
2000-01-01 00:00:00
|
||||
2003-12-31 12:34:56
|
||||
} {
|
||||
incr i
|
||||
set sqlite_current_time [execsql "SELECT strftime('%s','$date $time')"]
|
||||
do_test table-13.2.$i {
|
||||
execsql "
|
||||
INSERT INTO tablet8(a) VALUES($i);
|
||||
SELECT tm, dt, dttm FROM tablet8 WHERE a=$i;
|
||||
"
|
||||
} [list $time $date [list $date $time]]
|
||||
}
|
||||
set sqlite_current_time 0
|
||||
|
||||
finish_test
|
||||
|
||||
Reference in New Issue
Block a user