ADDED Tests/tkt-01f20ea55a.eagle Index: Tests/tkt-01f20ea55a.eagle ================================================================== --- /dev/null +++ Tests/tkt-01f20ea55a.eagle @@ -0,0 +1,101 @@ +############################################################################### +# +# tkt-01f20ea55a.eagle -- +# +# Written by Joe Mistachkin. +# Released to the public domain, use at your own risk! +# +############################################################################### + +package require Eagle +package require Eagle.Library +package require Eagle.Test + +runTestPrologue + +############################################################################### + +package require System.Data.SQLite.Test +runSQLiteTestPrologue + +############################################################################### + +set rawValue(0) "2016-10-01 12:34:56.8765401" + +############################################################################### + +set ticksValue(0) [getDateTimeTicks $rawValue(0)] +set ticksValue(1) [getDateTimeTicks $rawValue(0) false] + +############################################################################### + +set instanceValue(0) [object create -alias DateTime $ticksValue(0)] +set instanceValue(1) [object create -alias DateTime $ticksValue(1) Utc] + +############################################################################### + +runTest {test tkt-01f20ea55a-1.1 {DateTimeKind with DataTable} -setup { + proc dateTimeValueCallback { dataTable dataRow index value } { + if {[object isoftype $value DateTime]} then { + return [list [$value Kind] [$value ToString [getDateTimeFormat]]] + } else { + continue + } + } + + setupDb [set fileName tkt-01f20ea55a-1.1.db] "" ISO8601 Utc +} -body { + set connection [getDbConnection] + + sql execute $db [subst { + CREATE TABLE t1 (x, y DATETIME); + INSERT INTO t1 (x, y) VALUES(1, NULL); + }] + + sql execute $db "INSERT INTO t1 (x, y) VALUES(2, ?);" \ + [list param1 DateTime $instanceValue(0)] + + sql execute $db "INSERT INTO t1 (x, y) VALUES(3, ?);" \ + [list param1 DateTime $instanceValue(1)] + + set command [$connection -alias CreateCommand] + $command CommandText {SELECT x, y FROM t1 ORDER BY x;} + + set dataAdapter [object create -alias \ + System.Data.SQLite.SQLiteDataAdapter $command] + + set dataTable [object create -alias System.Data.DataTable] + + set dataColumn(x) [object create -alias System.Data.DataColumn x] + set dataColumn(y) [object create -alias System.Data.DataColumn y] + + $dataColumn(y) DataType DateTime; $dataColumn(y) DateTimeMode Utc + + $dataTable Columns.Add $dataColumn(x) + $dataTable Columns.Add $dataColumn(y) + + $dataAdapter Fill $dataTable + getRowsFromDataTable $dataTable dateTimeValueCallback +} -cleanup { + unset -nocomplain dataColumn dataTable dataAdapter command + + freeDbConnection + + cleanupDb $fileName + + unset -nocomplain connection db fileName + + rename dateTimeValueCallback "" +} -constraints {eagle command.object monoBug28 monoBug211 command.sql\ +compile.DATA SQLite System.Data.SQLite} -result {{{x 1} y} {{x 2} {y\ +{Utc {2016-10-01 12:34:56.8765401Z}}}} {{x 3} {y {Utc {2016-10-01\ +12:34:56.8765401Z}}}}}} + +############################################################################### + +unset -nocomplain instanceValue ticksValue rawValue + +############################################################################### + +runSQLiteTestEpilogue +runTestEpilogue