Sqlite: Map DATETIME to System.DateTime. Fixes #5078.
authorRolf Bjarne Kvinge <rolf@xamarin.com>
Fri, 18 May 2012 12:30:30 +0000 (14:30 +0200)
committerRolf Bjarne Kvinge <rolf@xamarin.com>
Fri, 18 May 2012 12:30:43 +0000 (14:30 +0200)
mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteConvert.cs
mcs/class/Mono.Data.Sqlite/Test/SqliteDataReaderTest.cs

index 386f912aab117fec9618d956a3d01a2c6a6cb39a..575c2ea04baaaf7942e9f7d7ddc03051e3df2dcc 100644 (file)
@@ -695,6 +695,7 @@ namespace Mono.Data.Sqlite
       new SQLiteTypeNames("SMALLINT", DbType.Int16),\r
       new SQLiteTypeNames("BIGINT", DbType.Int64),\r
       new SQLiteTypeNames("TIMESTAMP", DbType.DateTime),\r
+      new SQLiteTypeNames("DATETIME", DbType.DateTime),\r
     };\r
   }\r
 \r
index 6749079d62ddb47ecbd80f9449a4573a7cc17c90..5b9e627deee7e8ff4458d7aac0560a7816e5e422 100644 (file)
@@ -175,5 +175,34 @@ namespace MonoTests.Mono.Data.Sqlite
                                }
                        }
                }
+
+               [Test]
+               public void TestDateTimeType ()
+               {
+                       _conn.ConnectionString = _connectionString;
+                       using (_conn) {
+                               _conn.Open();
+                               
+                               using (var cm = _conn.CreateCommand ()) {
+                                       cm.CommandText = "DROP TABLE TEST; CREATE TABLE TEST (F2 DATETIME); INSERT INTO TEST (F2) VALUES (:F2)";
+
+                                       var dp2 = cm.CreateParameter ();
+                                       dp2.ParameterName = ":F2";
+                                       dp2.Value = DateTime.Now;
+                                       cm.Parameters.Add (dp2);
+                                       
+                                       cm.ExecuteNonQuer y();
+                               }
+                               
+                               using (var cm = _conn.CreateCommand ()) {
+                                       cm.CommandText = "SELECT F2 FROM TEST";
+                                       using (var dr = cm.ExecuteReader ()) {
+                                               dr.Read ();
+                                               
+                                               Assert.AreEqual ("System.DateTime", dr.GetFieldType (dr.GetOrdinal ("F2")).ToString ());
+                                       }
+                               }
+                       }
+               }
         }
 }