specify data type translation for mssql ODBC database Date->"smalldatetime"
authorRuss Tyndall <russ@acceleration.net>
Wed, 8 Jun 2011 18:19:30 +0000 (14:19 -0400)
committerNathan Bird <nathan@acceleration.net>
Mon, 20 Jun 2011 20:55:22 +0000 (16:55 -0400)
db-odbc/odbc-dbi.lisp
sql/generic-odbc.lisp
tests/test-fddl.lisp

index 073bd746845df6d81cdf8436c3a3d2baade57efe..bcca4b18004554f766ece0ecdcb9a173036b29ba 100644 (file)
@@ -452,23 +452,19 @@ This makes the functions db-execute-command and db-query thread safe."
     (setf computed-result-types (make-array column-count))
     (dotimes (i column-count)
       (setf (aref computed-result-types i)
-        (cond
-         ((consp result-types)
-          (nth i result-types))
-         ((eq result-types :auto)
-          (if (eq (aref column-sql-types i) odbc::$SQL_BIGINT)
-              :number
-            (case (aref column-c-types i)
-              (#.odbc::$SQL_BIT :short)
-              (#.odbc::$SQL_C_SLONG :int)
-              (#.odbc::$SQL_C_DOUBLE :double)
-              (#.odbc::$SQL_C_FLOAT :float)
-              (#.odbc::$SQL_C_SSHORT :short)
-              (#.odbc::$SQL_C_STINYINT :short)
-              (#.odbc::$SQL_BIGINT :short)
-              (t t))))
-          (t
-           t)))))
+            (cond
+              ((consp result-types)
+               (nth i result-types))
+              ((eq result-types :auto)
+               (case (aref column-c-types i)
+                 (#.odbc::$SQL_C_SLONG :int)
+                 (#.odbc::$SQL_C_DOUBLE :double)
+                 (#.odbc::$SQL_C_FLOAT :float)
+                 (#.odbc::$SQL_C_SSHORT :short)
+                 (#.odbc::$SQL_C_STINYINT :short)
+                 (#.odbc::$SQL_C_TYPE_TIMESTAMP :time)
+                 (t t)))
+              (t t)))))
   query)
 
 (defun db-close-query (query &key drop-p)
index 766606035a3c2cc2f64e6e5d3f194becce3ff28e..bd4d01cda033156bd6c0ff4aa0e6346cfca2a819 100644 (file)
   (declare (ignore args database))
   "DATETIME")
 
+(defmethod database-get-type-specifier ((type (eql 'date)) args database
+                                        (db-type (eql :mssql)))
+  (declare (ignore args database))
+  "SMALLDATETIME")
+
 (defmethod database-get-type-specifier ((type (eql 'boolean)) args database
                                         (db-type (eql :mssql)))
   (declare (ignore args database))
index ed25a04d2b9a65a396d5aa4b8064cd6b2b7086a0..04d310ec86454fadfe7e22463bc76c10ff2e3f8c 100644 (file)
@@ -174,7 +174,8 @@ B varchar(32))")
 
 (deftest :fddl/attributes/5
     (with-dataset *ds-fddl*
-      (and (member (clsql:attribute-type [d] [alpha]) '(:datetime :timestamp :date)) t))
+      (and (member (clsql:attribute-type [d] [alpha])
+                   '(:datetime :timestamp :date :smalldatetime)) t))
   t)
 
 (deftest :fddl/attributes/6