Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | When returning schema information that may be used by the .NET Framework to construct dynamic SQL, use a fake schema name (instead of null) so that the table names will be properly qualified with the catalog name (i.e. the attached database name). Refactor handling of arguments for the setupDb unit test infrastructure procedure. Allow the build and binary directories used by the unit testing infrastructure to be overridden. Add more tests related to ticket [343d392b51]. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | tkt-343d392b51 |
Files: | files | file ages | folders |
SHA1: |
2d2ef4ffcc594e99038f7f6c9389782c |
User & Date: | mistachkin 2011-10-08 11:01:44.399 |
Context
2011-10-09
| ||
03:19 | Copy the fix for the Bind_DateTime method to the SQLite3_UTF16 class. Add DateTimeKind connection string property to control the DateTimeKind of parsed DateTime values. Add the necessary method overloads to allow the DateTimeFormat and/or DateTimeKind to be specified by external callers. Reorganize the recognized DateTime formats so that ones with more information are always tried first. Also, add variants that support a trailing timezone specifier. Centralize DateTime format handling in the unit test infrastructure via the new getDateTimeFormat procedure. Revise setupDb unit test infrastructure procedure to accept a DateTimeKind. More changes to tests for ticket [343d392b51]. check-in: df7dcd3166 user: mistachkin tags: tkt-343d392b51 | |
2011-10-08
| ||
11:01 | When returning schema information that may be used by the .NET Framework to construct dynamic SQL, use a fake schema name (instead of null) so that the table names will be properly qualified with the catalog name (i.e. the attached database name). Refactor handling of arguments for the setupDb unit test infrastructure procedure. Allow the build and binary directories used by the unit testing infrastructure to be overridden. Add more tests related to ticket [343d392b51]. check-in: 2d2ef4ffcc user: mistachkin tags: tkt-343d392b51 | |
2011-10-07
| ||
00:30 | Start of work to resolve ticket [343d392b51]. check-in: 030e404034 user: mistachkin tags: tkt-343d392b51 | |
Changes
Changes to System.Data.SQLite/SQLite3.cs.
︙ | ︙ | |||
260 261 262 263 264 265 266 267 268 269 270 271 272 273 | internal override string SQLiteLastError() { return SQLiteBase.SQLiteLastError(_sql); } internal override SQLiteStatement Prepare(SQLiteConnection cnn, string strSql, SQLiteStatement previous, uint timeoutMS, out string strRemain) { IntPtr stmt = IntPtr.Zero; IntPtr ptr = IntPtr.Zero; int len = 0; int n = 17; int retries = 0; byte[] b = ToUTF8(strSql); string typedefs = null; | > > > > > > > > > > > > > > > > > > > > | 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | internal override string SQLiteLastError() { return SQLiteBase.SQLiteLastError(_sql); } internal override SQLiteStatement Prepare(SQLiteConnection cnn, string strSql, SQLiteStatement previous, uint timeoutMS, out string strRemain) { if (!String.IsNullOrEmpty(strSql)) { // // NOTE: SQLite does not support the concept of separate schemas // in one database; therefore, remove the base schema name // used to smooth integration with the base .NET Framework // data classes. // string baseSchemaName = (cnn != null) ? cnn._baseSchemaName : null; if (!String.IsNullOrEmpty(baseSchemaName)) { strSql = strSql.Replace( String.Format("[{0}].", baseSchemaName), String.Empty); strSql = strSql.Replace( String.Format("{0}.", baseSchemaName), String.Empty); } } IntPtr stmt = IntPtr.Zero; IntPtr ptr = IntPtr.Zero; int len = 0; int n = 17; int retries = 0; byte[] b = ToUTF8(strSql); string typedefs = null; |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteConnection.cs.
︙ | ︙ | |||
48 49 50 51 52 53 54 55 56 57 58 59 60 61 | /// </item> /// <item> /// <description>DateTimeFormat</description> /// <description><b>Ticks</b> - Use DateTime.Ticks<br/><b>ISO8601</b> - Use ISO8601 DateTime format</description> /// <description>N</description> /// <description>ISO8601</description> /// </item> /// <item> /// <description>BinaryGUID</description> /// <description><b>True</b> - Store GUID columns in binary form<br/><b>False</b> - Store GUID columns as text</description> /// <description>N</description> /// <description>True</description> /// </item> /// <item> | > > > > > > > > > | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | /// </item> /// <item> /// <description>DateTimeFormat</description> /// <description><b>Ticks</b> - Use DateTime.Ticks<br/><b>ISO8601</b> - Use ISO8601 DateTime format</description> /// <description>N</description> /// <description>ISO8601</description> /// </item> /// <item> /// <description>BaseSchemaName</description> /// <description>Some base data classes in the framework (e.g. those that build SQL queries dynamically) /// assume that an ADO.NET provider cannot support an alternate catalog (i.e. database) without supporting /// alternate schemas as well; however, SQLite does not fit into this model. Therefore, this value is used /// as a placeholder and removed prior to preparing any SQL statements that may contain it.</description> /// <description>N</description> /// <description>sqlite_schema_stub</description> /// </item> /// <item> /// <description>BinaryGUID</description> /// <description><b>True</b> - Store GUID columns in binary form<br/><b>False</b> - Store GUID columns as text</description> /// <description>N</description> /// <description>True</description> /// </item> /// <item> |
︙ | ︙ | |||
148 149 150 151 152 153 154 155 156 157 158 159 160 161 | /// <description>N</description> /// <description>False</description> /// </item> /// </list> /// </remarks> public sealed partial class SQLiteConnection : DbConnection, ICloneable { private const int SQLITE_FCNTL_WIN32_AV_RETRY = 9; private const string _dataDirectory = "|DataDirectory|"; private const string _masterdb = "sqlite_master"; private const string _tempmasterdb = "sqlite_temp_master"; /// <summary> | > > > > > > > | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | /// <description>N</description> /// <description>False</description> /// </item> /// </list> /// </remarks> public sealed partial class SQLiteConnection : DbConnection, ICloneable { /// <summary> /// The default "stub" (i.e. placeholder) base schema name to use when /// returning column schema information. Used as the initial value of /// the BaseSchemaName property. /// </summary> private const string DefaultBaseSchemaName = "sqlite_schema_stub"; private const int SQLITE_FCNTL_WIN32_AV_RETRY = 9; private const string _dataDirectory = "|DataDirectory|"; private const string _masterdb = "sqlite_master"; private const string _tempmasterdb = "sqlite_temp_master"; /// <summary> |
︙ | ︙ | |||
191 192 193 194 195 196 197 198 199 200 201 202 203 204 | /// </summary> private string _dataSource; /// <summary> /// Temporary password storage, emptied after the database has been opened /// </summary> private byte[] _password; /// <summary> /// Default command timeout /// </summary> private int _defaultTimeout = 30; internal bool _binaryGuid; | > > > > > > | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | /// </summary> private string _dataSource; /// <summary> /// Temporary password storage, emptied after the database has been opened /// </summary> private byte[] _password; /// <summary> /// The "stub" (i.e. placeholder) base schema name to use when returning /// column schema information. /// </summary> internal string _baseSchemaName; /// <summary> /// Default command timeout /// </summary> private int _defaultTimeout = 30; internal bool _binaryGuid; |
︙ | ︙ | |||
800 801 802 803 804 805 806 807 808 809 810 811 812 813 | int maxPoolSize = Convert.ToInt32(FindKey(opts, "Max Pool Size", "100"), CultureInfo.InvariantCulture); _defaultTimeout = Convert.ToInt32(FindKey(opts, "Default Timeout", "30"), CultureInfo.CurrentCulture); _defaultIsolation = (IsolationLevel)Enum.Parse(typeof(IsolationLevel), FindKey(opts, "Default IsolationLevel", "Serializable"), true); if (_defaultIsolation != IsolationLevel.Serializable && _defaultIsolation != IsolationLevel.ReadCommitted) throw new NotSupportedException("Invalid Default IsolationLevel specified"); //string temp = FindKey(opts, "DateTimeFormat", "ISO8601"); //if (String.Compare(temp, "ticks", StringComparison.OrdinalIgnoreCase) == 0) dateFormat = SQLiteDateFormats.Ticks; //else if (String.Compare(temp, "julianday", StringComparison.OrdinalIgnoreCase) == 0) dateFormat = SQLiteDateFormats.JulianDay; if (_sql == null) { | > > | 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 | int maxPoolSize = Convert.ToInt32(FindKey(opts, "Max Pool Size", "100"), CultureInfo.InvariantCulture); _defaultTimeout = Convert.ToInt32(FindKey(opts, "Default Timeout", "30"), CultureInfo.CurrentCulture); _defaultIsolation = (IsolationLevel)Enum.Parse(typeof(IsolationLevel), FindKey(opts, "Default IsolationLevel", "Serializable"), true); if (_defaultIsolation != IsolationLevel.Serializable && _defaultIsolation != IsolationLevel.ReadCommitted) throw new NotSupportedException("Invalid Default IsolationLevel specified"); _baseSchemaName = FindKey(opts, "BaseSchemaName", DefaultBaseSchemaName); //string temp = FindKey(opts, "DateTimeFormat", "ISO8601"); //if (String.Compare(temp, "ticks", StringComparison.OrdinalIgnoreCase) == 0) dateFormat = SQLiteDateFormats.Ticks; //else if (String.Compare(temp, "julianday", StringComparison.OrdinalIgnoreCase) == 0) dateFormat = SQLiteDateFormats.JulianDay; if (_sql == null) { |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteDataReader.cs.
︙ | ︙ | |||
71 72 73 74 75 76 77 | internal bool _disposing; /// <summary> /// An array of rowid's for the active statement if CommandBehavior.KeyInfo is specified /// </summary> private SQLiteKeyReader _keyInfo; | > > > | > > > > > > > > | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | internal bool _disposing; /// <summary> /// An array of rowid's for the active statement if CommandBehavior.KeyInfo is specified /// </summary> private SQLiteKeyReader _keyInfo; /// <summary> /// Matches the version of the connection. /// </summary> internal long _version; /// <summary> /// The "stub" (i.e. placeholder) base schema name to use when returning /// column schema information. Matches the base schema name used by the /// associated connection. /// </summary> private string _baseSchemaName; /// <summary> /// Internal constructor, initializes the datareader and sets up to begin executing statements /// </summary> /// <param name="cmd">The SQLiteCommand this data reader is for</param> /// <param name="behave">The expected behavior of the data reader</param> internal SQLiteDataReader(SQLiteCommand cmd, CommandBehavior behave) { _throwOnDisposed = true; _command = cmd; _version = _command.Connection._version; _baseSchemaName = _command.Connection._baseSchemaName; _commandBehavior = behave; _activeStatementIndex = -1; _rowsAffected = -1; if (_command != null) NextResult(); |
︙ | ︙ | |||
636 637 638 639 640 641 642 643 644 645 646 647 648 649 | row[SchemaTableOptionalColumn.IsReadOnly] = false; row[SchemaTableOptionalColumn.IsRowVersion] = false; row[SchemaTableColumn.IsUnique] = false; row[SchemaTableColumn.IsKey] = false; row[SchemaTableOptionalColumn.IsAutoIncrement] = false; row[SchemaTableColumn.DataType] = GetFieldType(n); row[SchemaTableOptionalColumn.IsHidden] = false; strColumn = _command.Connection._sql.ColumnOriginalName(_activeStatement, n); if (String.IsNullOrEmpty(strColumn) == false) row[SchemaTableColumn.BaseColumnName] = strColumn; row[SchemaTableColumn.IsExpression] = String.IsNullOrEmpty(strColumn); row[SchemaTableColumn.IsAliased] = (String.Compare(GetName(n), strColumn, StringComparison.OrdinalIgnoreCase) != 0); | > | 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 | row[SchemaTableOptionalColumn.IsReadOnly] = false; row[SchemaTableOptionalColumn.IsRowVersion] = false; row[SchemaTableColumn.IsUnique] = false; row[SchemaTableColumn.IsKey] = false; row[SchemaTableOptionalColumn.IsAutoIncrement] = false; row[SchemaTableColumn.DataType] = GetFieldType(n); row[SchemaTableOptionalColumn.IsHidden] = false; row[SchemaTableColumn.BaseSchemaName] = _baseSchemaName; strColumn = _command.Connection._sql.ColumnOriginalName(_activeStatement, n); if (String.IsNullOrEmpty(strColumn) == false) row[SchemaTableColumn.BaseColumnName] = strColumn; row[SchemaTableColumn.IsExpression] = String.IsNullOrEmpty(strColumn); row[SchemaTableColumn.IsAliased] = (String.Compare(GetName(n), strColumn, StringComparison.OrdinalIgnoreCase) != 0); |
︙ | ︙ |
Changes to Tests/basic.eagle.
︙ | ︙ | |||
647 648 649 650 651 652 653 | {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} \ -result {0 1 2 2 1 2 2 2 {1 {{x 1} {y foobar} {z 1234}}} {2 {{x 2} {y foobar}\ {z 5678}}} 2 {1 {{x 1} {y foobar} {z 1234}}} {2 {{x 2} {y foobar} {z 5678}}}}} ############################################################################### runTest {test basic-1.12 {DateTime using Unix epoch} -setup { | | | 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 | {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} \ -result {0 1 2 2 1 2 2 2 {1 {{x 1} {y foobar} {z 1234}}} {2 {{x 2} {y foobar}\ {z 5678}}} 2 {1 {{x 1} {y foobar} {z 1234}}} {2 {{x 2} {y foobar} {z 5678}}}}} ############################################################################### runTest {test basic-1.12 {DateTime using Unix epoch} -setup { setupDb [set fileName basic-1.12.db] "" UnixEpoch } -body { set result [list] sql execute $db "CREATE TABLE t1(x INTEGER PRIMARY KEY ASC, y DATETIME);" sql execute $db "INSERT INTO t1 (x, y) VALUES(1, 1302825600);" sql execute $db "INSERT INTO t1 (x, y) VALUES(2, 1334448000);" sql execute $db "INSERT INTO t1 (x, y) VALUES(3, 1365984000);" |
︙ | ︙ | |||
701 702 703 704 705 706 707 | ############################################################################### set date [clock format [clock seconds] -format yyyy-MM-dd] ############################################################################### runTest {test basic-1.13 {DateTime using invariant culture} -setup { | | | 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 | ############################################################################### set date [clock format [clock seconds] -format yyyy-MM-dd] ############################################################################### runTest {test basic-1.13 {DateTime using invariant culture} -setup { setupDb [set fileName basic-1.13.db] "" InvariantCulture } -body { set result [list] sql execute $db "CREATE TABLE t1(x INTEGER PRIMARY KEY ASC, y DATETIME);" sql execute $db \ "INSERT INTO t1 (x, y) VALUES(1, 'Wednesday, 16 December 2009');" |
︙ | ︙ | |||
762 763 764 765 766 767 768 | ${date}T12:00:00.0000000Z}}} {9 {{x 9} {y2 2009-12-16T12:00:00.0000000Z}}}\ {10 {{x 10} {y2 2009-12-16T00:00:00.0000000Z}}} {11 {{x 11} {y2\ ${date}T12:00:00.0000000Z}}} {12 {{x 12} {y2 2009-12-16T12:00:00.0000000Z}}}}]} ############################################################################### runTest {test basic-1.14 {DateTime using current culture} -setup { | | | 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 | ${date}T12:00:00.0000000Z}}} {9 {{x 9} {y2 2009-12-16T12:00:00.0000000Z}}}\ {10 {{x 10} {y2 2009-12-16T00:00:00.0000000Z}}} {11 {{x 11} {y2\ ${date}T12:00:00.0000000Z}}} {12 {{x 12} {y2 2009-12-16T12:00:00.0000000Z}}}}]} ############################################################################### runTest {test basic-1.14 {DateTime using current culture} -setup { setupDb [set fileName basic-1.14.db] "" CurrentCulture } -body { set result [list] sql execute $db "CREATE TABLE t1(x INTEGER PRIMARY KEY ASC, y DATETIME);" sql execute $db \ "INSERT INTO t1 (x, y) VALUES(1, 'Wednesday, 16 December 2009');" |
︙ | ︙ |
Changes to Tests/common.eagle.
︙ | ︙ | |||
104 105 106 107 108 109 110 | # release of Eagle, the following command must be used instead # (also all on one line): # # EagleShell.exe -initialize -postInitialize # "object invoke Interpreter.GetActive AddRuntimeOption native" # -file .\path\to\all.eagle # | > > > > > > > | | | | | | | > > > > > > > > | > | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | # release of Eagle, the following command must be used instead # (also all on one line): # # EagleShell.exe -initialize -postInitialize # "object invoke Interpreter.GetActive AddRuntimeOption native" # -file .\path\to\all.eagle # if {[info exists ::build_directory] && \ [string length $::build_directory] > 0} then { # # NOTE: The location of the build directory has been overridden. # return $::build_directory } else { if {[hasRuntimeOption native]} then { return [file join [file dirname $::path] bin [getBuildYear] \ [machineToPlatform $::tcl_platform(machine)] \ [getBuildConfiguration]] } else { return [file join [file dirname $::path] bin [getBuildYear] \ [getBuildConfiguration] bin] } } } proc getBuildFileName { fileName } { return [file nativename \ [file join [getBuildDirectory] [file tail $fileName]]] } proc getBinaryDirectory {} { # # NOTE: This procedure returns the directory where the test application # itself (i.e. the Eagle shell) is located. This will be used as # the destination for the copied System.Data.SQLite native and # managed assemblies (i.e. because this is one of the few places # where the CLR will actually find and load them properly). # if {[info exists ::binary_directory] && \ [string length $::binary_directory] > 0} then { # # NOTE: The location of the binary directory has been overridden. # return $::binary_directory } else { return [info binary] } } proc getBinaryFileName { fileName } { return [file nativename \ [file join [getBinaryDirectory] [file tail $fileName]]] } |
︙ | ︙ | |||
299 300 301 302 303 304 305 | # # NOTE: Evaluate the constructed [compileCSharp] command and return the # result. # eval $command } | | > > | | 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | # # NOTE: Evaluate the constructed [compileCSharp] command and return the # result. # eval $command } proc setupDb { fileName {mode ""} {dateTimeFormat ""} {extra ""} {delete true} {varName db}} { # # NOTE: For now, all test databases used by the test suite are placed into # the temporary directory. Each database used by a test should be # cleaned up by that test using the "cleanupDb" procedure, below. # set fileName [file join [getTemporaryPath] [file tail $fileName]] # # NOTE: By default, delete any pre-existing database with the same file # name. # if {$delete} then { catch {file delete $fileName} } # # NOTE: Refer to the specified variable (e.g. "db") in the context of the # caller. The handle to the opened database will be stored there. # |
︙ | ︙ | |||
334 335 336 337 338 339 340 341 342 343 344 345 346 347 | # # NOTE: If the caller specified a journal mode, add the necessary portion # of the connection string now. # if {[string length $mode] > 0} then { append connection {;Journal Mode=${mode}} } # # NOTE: If the caller specified an extra payload to the connection string, # append it now. # if {[string length $extra] > 0} then { append connection \; $extra | > > > > > > > > | 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | # # NOTE: If the caller specified a journal mode, add the necessary portion # of the connection string now. # if {[string length $mode] > 0} then { append connection {;Journal Mode=${mode}} } # # NOTE: If the caller specified a DateTime format, add the necessary # portion of the connection string now. # if {[string length $dateTimeFormat] > 0} then { append connection {;DateTimeFormat=${dateTimeFormat}} } # # NOTE: If the caller specified an extra payload to the connection string, # append it now. # if {[string length $extra] > 0} then { append connection \; $extra |
︙ | ︙ |
Changes to Tests/tkt-343d392b51.eagle.
︙ | ︙ | |||
16 17 18 19 20 21 22 | ############################################################################### package require System.Data.SQLite.Test runSQLiteTestPrologue ############################################################################### | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | 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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | ############################################################################### package require System.Data.SQLite.Test runSQLiteTestPrologue ############################################################################### set dateTimeFormats [list "" Ticks ISO8601 JulianDay UnixEpoch] for {set i 1} {$i < 5} {incr i} { set dateTimeFormat [lindex $dateTimeFormats $i] runTest {test [appendArgs tkt-343d392b51-1. $i] [subst {DateTime\ binding $dateTimeFormat format}] -setup { setupDb [set fileName [appendArgs tkt-343d392b51-1. $i .db]] "" \ $dateTimeFormat set dateTime "4 October, 2011 3:27:50 PM" } -body { sql execute $db "CREATE TABLE t1(x DATETIME);" set paramDateTime1 [clock format [clock scan $dateTime -gmt true] -format \ "yyyy-MM-dd HH:mm:ss.FFFFFFF" -gmt true] switch -exact -- $dateTimeFormat { Ticks { set paramDateTime1 [object invoke -alias DateTime SpecifyKind [set \ paramDateTime1 [object invoke DateTime Parse $paramDateTime1]] Utc] set paramDateTime1 [$paramDateTime1 Ticks] set paramDateTime2 $paramDateTime1 } ISO8601 { set paramDateTime2 [appendArgs ' $paramDateTime1 '] } JulianDay { set paramDateTime1 [object invoke -alias DateTime SpecifyKind [set \ paramDateTime1 [object invoke DateTime Parse $paramDateTime1]] Utc] set paramDateTime1 [expr {[$paramDateTime1 ToOADate] + 2415018.5}] set paramDateTime2 $paramDateTime1 } UnixEpoch { set paramDateTime1 [clock scan $dateTime -gmt true] set paramDateTime2 $paramDateTime1 } } sql execute $db [appendArgs "INSERT INTO t1 (x) VALUES(" $paramDateTime2 \ ");"] list [sql execute -verbatim -execute reader -format list -datetimeformat \ yyyy-MM-ddTHH:mm:ss $db "SELECT x FROM t1 WHERE x = ?;" \ [list param1 String $paramDateTime1]] \ [sql execute -verbatim -execute reader -format list -datetimeformat \ yyyy-MM-ddTHH:mm:ss $db "SELECT x FROM t1 WHERE x = ?;" \ [list param1 DateTime $paramDateTime1]] } -cleanup { cleanupDb $fileName unset -nocomplain paramDateTime2 paramDateTime1 dateTime db fileName } -constraints {eagle monoBug28 command.sql compile.DATA SQLite\ System.Data.SQLite} -result {2011-10-04T15:27:50 2011-10-04T15:27:50}} } ############################################################################### unset -nocomplain dateTimeFormat i dateTimeFormats ############################################################################### runTest {test tkt-343d392b51-2.1 {SQLiteDataAdapter batch updates} -setup { setupDb [set fileName tkt-343d392b51-2.1.db] set otherFileName tkt-343d392b51-2.1-otherDb.db } -body { set id [object invoke Interpreter.GetActive NextId] set dataSource [file join [getTemporaryPath] $fileName] set otherDataSource [file join [getTemporaryPath] $otherFileName] set otherDbName otherDb set table [appendArgs $otherDbName .t1] set sql(inserts) "" set sql(1) [subst { \ ATTACH DATABASE '${otherDataSource}' AS ${otherDbName}; \ CREATE TABLE ${table}(x INTEGER PRIMARY KEY, y DATETIME); \ [for {set i 1} {$i < 3} {incr i} { append sql(inserts) [appendArgs \ "INSERT INTO " ${table} " (x, y) VALUES(" $i ", '" \ [clock format $i -format {yyyy-MM-ddTHH:mm:ss}] "'); "] }; return [expr {[info exists sql(inserts)] ? $sql(inserts) : ""}]] \ }] set sql(2) [subst { \ SELECT x, y FROM ${table} ORDER BY x; \ }] unset -nocomplain results errors set code [compileCSharpWith [subst { using System; using System.Data; using System.Data.SQLite; namespace _Dynamic${id} { public class Test${id} { public static void Main() { using (SQLiteConnection connection = new SQLiteConnection( "Data Source=${dataSource};")) { connection.Open(); using (SQLiteCommand command = connection.CreateCommand()) { command.CommandText = "${sql(1)}"; command.ExecuteNonQuery(); } using (SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter( "${sql(2)}", connection)) { using (DataSet dataSet = new DataSet()) { dataAdapter.Fill(dataSet, "${table}"); DataTable dataTable = dataSet.Tables\["${table}"\]; dataTable.Columns\["x"\].Unique = true; dataTable.PrimaryKey = new DataColumn\[\] { dataTable.Columns\["x"\] }; [expr {[isMono] ? "#pragma warning disable 219" : ""}] SQLiteCommandBuilder commandBuilder = new SQLiteCommandBuilder(dataAdapter); [expr {[isMono] ? "#pragma warning restore 219" : ""}] foreach (DataRow dataRow in dataTable.Rows) { // // NOTE: Update even rows and delete odd rows. // if ((long)dataRow\["x"\] % 2 == 0) dataRow\["y"\] = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss"); else dataRow.Delete(); } dataAdapter.Update(dataTable); // DBConcurrencyException (?) } } } } } } }] results errors System.Data.SQLite.dll] list $code $results \ [expr {[info exists errors] ? $errors : ""}] \ [expr {$code eq "Ok" ? [catch { object invoke _Dynamic${id}.Test${id} Main } result] : [set result ""]}] $result } -cleanup { cleanupDb $otherFileName cleanupDb $fileName unset -nocomplain result code results errors i sql table otherDbName \ otherDataSource dataSource id db otherFileName fileName } -constraints \ {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \ glob -result {* System.Data.DBConcurrencyException: *}} ############################################################################### runTest {test tkt-343d392b51-2.2 {SQLiteDataAdapter batch updates} -setup { setupDb [set fileName tkt-343d392b51-2.2.db] "" JulianDay set otherFileName tkt-343d392b51-2.2-otherDb.db } -body { set id [object invoke Interpreter.GetActive NextId] set dataSource [file join [getTemporaryPath] $fileName] set otherDataSource [file join [getTemporaryPath] $otherFileName] set otherDbName otherDb set table [appendArgs $otherDbName .t1] set sql(inserts) "" set sql(1) [subst { \ ATTACH DATABASE '${otherDataSource}' AS ${otherDbName}; \ CREATE TABLE ${table}(x INTEGER PRIMARY KEY, y DATETIME); \ [for {set i 1} {$i < 3} {incr i} { append sql(inserts) [appendArgs \ "INSERT INTO " ${table} " (x, y) VALUES(" $i ", JULIANDAY('" \ [clock format $i -format {yyyy-MM-ddTHH:mm:ss}] "')); "] }; return [expr {[info exists sql(inserts)] ? $sql(inserts) : ""}]] \ }] set sql(2) [subst { \ |
︙ | ︙ | |||
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | DataTable dataTable = dataSet.Tables\["${table}"\]; dataTable.Columns\["x"\].Unique = true; dataTable.PrimaryKey = new DataColumn\[\] { dataTable.Columns\["x"\] }; SQLiteCommandBuilder commandBuilder = new SQLiteCommandBuilder(dataAdapter); foreach (DataRow dataRow in dataTable.Rows) { // // NOTE: Update even rows and delete odd rows. // if ((long)dataRow\["x"\] % 2 == 0) | > > | 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | DataTable dataTable = dataSet.Tables\["${table}"\]; dataTable.Columns\["x"\].Unique = true; dataTable.PrimaryKey = new DataColumn\[\] { dataTable.Columns\["x"\] }; [expr {[isMono] ? "#pragma warning disable 219" : ""}] SQLiteCommandBuilder commandBuilder = new SQLiteCommandBuilder(dataAdapter); [expr {[isMono] ? "#pragma warning restore 219" : ""}] foreach (DataRow dataRow in dataTable.Rows) { // // NOTE: Update even rows and delete odd rows. // if ((long)dataRow\["x"\] % 2 == 0) |
︙ | ︙ |
Changes to Tests/tkt-448d663d11.eagle.
︙ | ︙ | |||
32 33 34 35 36 37 38 | ############################################################################### runTest {test tkt-448d663d11-1.2 {missing journal mode, WAL db} -body { set fileName tkt-448d663d11-1.2.db file copy -force [file join $path wal.db] \ [file join [getTemporaryPath] $fileName] | | | | 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 | ############################################################################### runTest {test tkt-448d663d11-1.2 {missing journal mode, WAL db} -body { set fileName tkt-448d663d11-1.2.db file copy -force [file join $path wal.db] \ [file join [getTemporaryPath] $fileName] setupDb $fileName "" "" "" false sql execute -execute scalar $db "PRAGMA journal_mode;" } -cleanup { cleanupDb $fileName unset -nocomplain db fileName } -constraints \ {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \ {wal}} ############################################################################### runTest {test tkt-448d663d11-1.3 {missing journal mode, non-WAL db} -body { set fileName tkt-448d663d11-1.3.db file copy -force [file join $path nonWal.db] \ [file join [getTemporaryPath] $fileName] setupDb $fileName "" "" "" false sql execute -execute scalar $db "PRAGMA journal_mode;" } -cleanup { cleanupDb $fileName unset -nocomplain db fileName } -constraints \ {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \ {delete}} |
︙ | ︙ | |||
74 75 76 77 78 79 80 | ############################################################################### runTest {test tkt-448d663d11-1.5 {'Default' journal mode, WAL db} -body { set fileName tkt-448d663d11-1.5.db file copy -force [file join $path wal.db] \ [file join [getTemporaryPath] $fileName] | | | | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | ############################################################################### runTest {test tkt-448d663d11-1.5 {'Default' journal mode, WAL db} -body { set fileName tkt-448d663d11-1.5.db file copy -force [file join $path wal.db] \ [file join [getTemporaryPath] $fileName] setupDb $fileName Default "" "" false sql execute -execute scalar $db "PRAGMA journal_mode;" } -cleanup { cleanupDb $fileName unset -nocomplain db fileName } -constraints \ {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \ {wal}} ############################################################################### runTest {test tkt-448d663d11-1.6 {'Default' journal mode, non-WAL db} -body { set fileName tkt-448d663d11-1.6.db file copy -force [file join $path nonWal.db] \ [file join [getTemporaryPath] $fileName] setupDb $fileName Default "" "" false sql execute -execute scalar $db "PRAGMA journal_mode;" } -cleanup { cleanupDb $fileName unset -nocomplain db fileName } -constraints \ {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \ {delete}} |
︙ | ︙ | |||
116 117 118 119 120 121 122 | ############################################################################### runTest {test tkt-448d663d11-1.8 {'Delete' journal mode, WAL db} -body { set fileName tkt-448d663d11-1.8.db file copy -force [file join $path wal.db] \ [file join [getTemporaryPath] $fileName] | | | | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | ############################################################################### runTest {test tkt-448d663d11-1.8 {'Delete' journal mode, WAL db} -body { set fileName tkt-448d663d11-1.8.db file copy -force [file join $path wal.db] \ [file join [getTemporaryPath] $fileName] setupDb $fileName Delete "" "" false sql execute -execute scalar $db "PRAGMA journal_mode;" } -cleanup { cleanupDb $fileName unset -nocomplain db fileName } -constraints \ {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \ {delete}} ############################################################################### runTest {test tkt-448d663d11-1.9 {'Delete' journal mode, non-WAL db} -body { set fileName tkt-448d663d11-1.9.db file copy -force [file join $path nonWal.db] \ [file join [getTemporaryPath] $fileName] setupDb $fileName Delete "" "" false sql execute -execute scalar $db "PRAGMA journal_mode;" } -cleanup { cleanupDb $fileName unset -nocomplain db fileName } -constraints \ {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \ {delete}} |
︙ | ︙ | |||
206 207 208 209 210 211 212 | ############################################################################### runTest {test tkt-448d663d11-1.15 {'Wal' journal mode, non-WAL db} -body { set fileName tkt-448d663d11-1.15.db file copy -force [file join $path nonWal.db] \ [file join [getTemporaryPath] $fileName] | | | | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | ############################################################################### runTest {test tkt-448d663d11-1.15 {'Wal' journal mode, non-WAL db} -body { set fileName tkt-448d663d11-1.15.db file copy -force [file join $path nonWal.db] \ [file join [getTemporaryPath] $fileName] setupDb $fileName Wal "" "" false sql execute -execute scalar $db "PRAGMA journal_mode;" } -cleanup { cleanupDb $fileName unset -nocomplain db fileName } -constraints \ {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \ {wal}} ############################################################################### runTest {test tkt-448d663d11-1.16 {'Wal' journal mode, WAL db} -body { set fileName tkt-448d663d11-1.16.db file copy -force [file join $path wal.db] \ [file join [getTemporaryPath] $fileName] setupDb $fileName Wal "" "" false sql execute -execute scalar $db "PRAGMA journal_mode;" } -cleanup { cleanupDb $fileName unset -nocomplain db fileName } -constraints \ {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \ {wal}} |
︙ | ︙ | |||
248 249 250 251 252 253 254 | ############################################################################### runTest {test tkt-448d663d11-1.18 {'Bad' journal mode, non-WAL db} -body { set fileName tkt-448d663d11-1.18.db file copy -force [file join $path nonWal.db] \ [file join [getTemporaryPath] $fileName] | | | | 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | ############################################################################### runTest {test tkt-448d663d11-1.18 {'Bad' journal mode, non-WAL db} -body { set fileName tkt-448d663d11-1.18.db file copy -force [file join $path nonWal.db] \ [file join [getTemporaryPath] $fileName] setupDb $fileName Bad "" "" false sql execute -execute scalar $db "PRAGMA journal_mode;" } -cleanup { cleanupDb $fileName unset -nocomplain db fileName } -constraints \ {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \ {delete}} ############################################################################### runTest {test tkt-448d663d11-1.19 {'Bad' journal mode, WAL db} -body { set fileName tkt-448d663d11-1.19.db file copy -force [file join $path wal.db] \ [file join [getTemporaryPath] $fileName] setupDb $fileName Bad "" "" false sql execute -execute scalar $db "PRAGMA journal_mode;" } -cleanup { cleanupDb $fileName unset -nocomplain db fileName } -constraints \ {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \ {wal}} ############################################################################### runSQLiteTestEpilogue runTestEpilogue |
Changes to Tests/tkt-b4a7ddc83f.eagle.
︙ | ︙ | |||
28 29 30 31 32 33 34 | object invoke -flags +NonPublic System.Data.SQLite.UnsafeNativeMethods \ sqlite3_shutdown } ############################################################################### for {set i 1} {$i < 3} {incr i} { | | | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | object invoke -flags +NonPublic System.Data.SQLite.UnsafeNativeMethods \ sqlite3_shutdown } ############################################################################### for {set i 1} {$i < 3} {incr i} { runTest {test [appendArgs tkt-b4a7ddc83f-1. $i] {logging shutdown} -setup \ [getAppDomainPreamble { set appDomainId(1) {[object invoke AppDomain.CurrentDomain Id]} set fileName {[appendArgs tkt-b4a7ddc83f-1. $i .db]} }] -body { set appDomainId(2) [object invoke AppDomain.CurrentDomain Id] package require EagleLibrary package require EagleTest package require System.Data.SQLite.Test |
︙ | ︙ |