From ac8069e4f04d9c4faa41664cb8ee1ec83df0e67f Mon Sep 17 00:00:00 2001 From: Russ Tyndall Date: Wed, 8 Jun 2011 14:19:30 -0400 Subject: [PATCH] specify data type translation for mssql ODBC database Date->"smalldatetime" --- db-odbc/odbc-dbi.lisp | 30 +++++++++++++----------------- sql/generic-odbc.lisp | 5 +++++ tests/test-fddl.lisp | 3 ++- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/db-odbc/odbc-dbi.lisp b/db-odbc/odbc-dbi.lisp index 073bd74..bcca4b1 100644 --- a/db-odbc/odbc-dbi.lisp +++ b/db-odbc/odbc-dbi.lisp @@ -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) diff --git a/sql/generic-odbc.lisp b/sql/generic-odbc.lisp index 7666060..bd4d01c 100644 --- a/sql/generic-odbc.lisp +++ b/sql/generic-odbc.lisp @@ -77,6 +77,11 @@ (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)) diff --git a/tests/test-fddl.lisp b/tests/test-fddl.lisp index ed25a04..04d310e 100644 --- a/tests/test-fddl.lisp +++ b/tests/test-fddl.lisp @@ -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 -- 2.34.1