Index: Setup/data/verify.lst ================================================================== --- Setup/data/verify.lst +++ Setup/data/verify.lst @@ -886,10 +886,11 @@ Tests/tkt-964063da16.eagle Tests/tkt-996d13cd87.eagle Tests/tkt-9ba9346f75.eagle Tests/tkt-9d353b0bd8.eagle Tests/tkt-a4d9c7ee94.eagle + Tests/tkt-a799e3978f.eagle Tests/tkt-a7d04fb111.eagle Tests/tkt-aba4549801.eagle Tests/tkt-ac47dd230a.eagle Tests/tkt-ae5267b863.eagle Tests/tkt-b167206ad3.eagle Index: System.Data.SQLite/SQLiteConvert.cs ================================================================== --- System.Data.SQLite/SQLiteConvert.cs +++ System.Data.SQLite/SQLiteConvert.cs @@ -1249,10 +1249,14 @@ typeof(Int64), // Int64 (1) typeof(Double), // Double (2) typeof(string), // Text (3) typeof(byte[]), // Blob (4) typeof(object), // Null (5) + null, // Undefined (6) + null, // Undefined (7) + null, // Undefined (8) + null, // Undefined (9) typeof(DateTime), // DateTime (10) typeof(object) // None (11) }; /// @@ -1328,11 +1332,13 @@ 8, // UInt64 (20) 8, // VarNumeric (21) int.MaxValue, // AnsiStringFixedLength (22) int.MaxValue, // StringFixedLength (23) int.MaxValue, // ?? (24) - int.MaxValue // Xml (25) + int.MaxValue, // Xml (25) + 8, // DateTime2 (26) + 10 // DateTimeOffset (27) }; internal static object DbTypeToNumericPrecision(DbType typ) { return _dbtypetonumericprecision[(int)typ]; @@ -1362,11 +1368,13 @@ 19, // UInt64 (20) 53, // VarNumeric (21) DBNull.Value, // AnsiStringFixedLength (22) DBNull.Value, // StringFixedLength (23) DBNull.Value, // ?? (24) - DBNull.Value // Xml (25) + DBNull.Value, // Xml (25) + DBNull.Value, // DateTime2 (26) + DBNull.Value // DateTimeOffset (27) }; internal static object DbTypeToNumericScale(DbType typ) { return _dbtypetonumericscale[(int)typ]; @@ -1396,11 +1404,13 @@ 0, // UInt64 (20) 0, // VarNumeric (21) DBNull.Value, // AnsiStringFixedLength (22) DBNull.Value, // StringFixedLength (23) DBNull.Value, // ?? (24) - DBNull.Value // Xml (25) + DBNull.Value, // Xml (25) + DBNull.Value, // DateTime2 (26) + DBNull.Value // DateTimeOffset (27) }; /// /// Determines the default database type name to be used when a /// per-connection value is not available. @@ -1590,36 +1600,46 @@ { return _dbtypeToType[(int)typ]; } private static Type[] _dbtypeToType = { - typeof(string), // AnsiString (0) - typeof(byte[]), // Binary (1) - typeof(byte), // Byte (2) - typeof(bool), // Boolean (3) - typeof(decimal), // Currency (4) - typeof(DateTime), // Date (5) - typeof(DateTime), // DateTime (6) - typeof(decimal), // Decimal (7) - typeof(double), // Double (8) - typeof(Guid), // Guid (9) - typeof(Int16), // Int16 (10) - typeof(Int32), // Int32 (11) - typeof(Int64), // Int64 (12) - typeof(object), // Object (13) - typeof(sbyte), // SByte (14) - typeof(float), // Single (15) - typeof(string), // String (16) - typeof(DateTime), // Time (17) - typeof(UInt16), // UInt16 (18) - typeof(UInt32), // UInt32 (19) - typeof(UInt64), // UInt64 (20) - typeof(double), // VarNumeric (21) - typeof(string), // AnsiStringFixedLength (22) - typeof(string), // StringFixedLength (23) - typeof(string), // ?? (24) - typeof(string), // Xml (25) + typeof(string), // AnsiString (0) + typeof(byte[]), // Binary (1) + typeof(byte), // Byte (2) + typeof(bool), // Boolean (3) + typeof(decimal), // Currency (4) + typeof(DateTime), // Date (5) + typeof(DateTime), // DateTime (6) + typeof(decimal), // Decimal (7) + typeof(double), // Double (8) + typeof(Guid), // Guid (9) + typeof(Int16), // Int16 (10) + typeof(Int32), // Int32 (11) + typeof(Int64), // Int64 (12) + typeof(object), // Object (13) + typeof(sbyte), // SByte (14) + typeof(float), // Single (15) + typeof(string), // String (16) + typeof(DateTime), // Time (17) + typeof(UInt16), // UInt16 (18) + typeof(UInt32), // UInt32 (19) + typeof(UInt64), // UInt64 (20) + typeof(double), // VarNumeric (21) + typeof(string), // AnsiStringFixedLength (22) + typeof(string), // StringFixedLength (23) + typeof(string), // ?? (24) + typeof(string), // Xml (25) + typeof(DateTime), // DateTime2 (26) +#if NET_35 || NET_40 || NET_45 || NET_451 || NET_452 || NET_46 || NET_461 || NET_462 || NET_47 || NET_471 + // + // NOTE: This type is only available on the + // .NET Framework 2.0 SP1 and later. + // + typeof(DateTimeOffset) // DateTimeOffset (27) +#else + typeof(DateTime) // DateTimeOffset (27) +#endif }; /// /// For a given type, return the closest-match SQLite TypeAffinity, which only understands a very limited subset of types. /// ADDED Tests/tkt-a799e3978f.eagle Index: Tests/tkt-a799e3978f.eagle ================================================================== --- /dev/null +++ Tests/tkt-a799e3978f.eagle @@ -0,0 +1,63 @@ +############################################################################### +# +# tkt-a799e3978f.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 + +############################################################################### + +runTest {test tkt-a799e3978f-1.1 {DateTime2 type mapping} -setup { + setupDb [set fileName tkt-a799e3978f-1.1.db] "" "" "" UseConnectionTypes +} -body { + set connection [getDbConnection] + set result [list] + + lappend result [sql execute $db \ + "CREATE TABLE t1(x INTEGER PRIMARY KEY, y DATETIME2);"] + + set dateTime [clock format [clock scan "2014-02-01 12:34:56Z"] \ + -format yyyyMMddHHmmss -gmt true] + + lappend result [sql execute $db [appendArgs \ + "INSERT INTO t1 (y) VALUES('" $dateTime "');"]] + + lappend result [sql execute -verbatim -execute reader -format list \ + -datetimeformat [getDateTimeFormat] $db "SELECT x, y FROM t1;"] + + lappend result [$connection ClearTypeMappings]; # 0 + lappend result [$connection AddTypeMapping DATETIME2 DateTime false]; # 0 + + lappend result [sql execute -verbatim -execute reader -format list \ + -datetimeformat [getDateTimeFormat] $db "SELECT x, y FROM t1;"] + + set result +} -cleanup { + freeDbConnection + + unset -nocomplain result connection + + cleanupDb $fileName + + unset -nocomplain dateTime db fileName +} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\ +System.Data.SQLite} -result \ +{0 1 {1 20140201123456} 0 0 {1 {2014-02-01 12:34:56}}}} + +############################################################################### + +runSQLiteTestEpilogue +runTestEpilogue