X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=sql%2Fgeneric-odbc.lisp;h=d64db208b1b3a62b190b4773624ab67cd8adb12b;hp=e4c37529f2e07a32778f46fe01b3ffa0d1c0e331;hb=f103c1a5416d2f22820d66020e4f9c18c766d894;hpb=85ec9eefa107bb000198c381ffba15c8f4bb086b diff --git a/sql/generic-odbc.lisp b/sql/generic-odbc.lisp index e4c3752..d64db20 100644 --- a/sql/generic-odbc.lisp +++ b/sql/generic-odbc.lisp @@ -72,24 +72,20 @@ ;;; Type methods -(defmethod database-get-type-specifier ((type (eql 'wall-time)) args database +(defmethod database-get-type-specifier ((type symbol) args database (db-type (eql :mssql))) - (declare (ignore args database)) - "DATETIME") -(defmethod database-get-type-specifier ((type (eql 'date)) args database - (db-type (eql :mssql))) - (declare (ignore args database)) - "DATETIME") - -(defmethod database-get-type-specifier ((type (eql 'boolean)) args database - (db-type (eql :mssql))) - (declare (ignore args database)) - "BIT") - -(defmethod database-get-type-specifier ((type (eql 'generalized-boolean)) args database - (db-type (eql :mssql))) - (declare (ignore args database)) - "BIT") + "Special database types for MSSQL backends" + (declare (ignore database db-type args)) + (case type + (wall-time "DATETIME") + (date "SMALLDATETIME") + ((generalized-boolean boolean) "BIT") + ((longchar text) "ntext") + ((varchar string) + (if args + (format nil "NVARCHAR(~A)" (car args)) + (format nil "NVARCHAR(~D)" *default-string-length*))) + (t (call-next-method)))) ;;; Generation of SQL strings from lisp expressions @@ -98,16 +94,6 @@ (:mssql "1") (t "'Y'"))) -(defmethod database-output-sql-as-type ((type (eql 'boolean)) val database - (db-type (eql :mssql))) - (declare (ignore database)) - (if val 1 0)) - -(defmethod database-output-sql-as-type ((type (eql 'generalized-boolean)) val database - (db-type (eql :mssql))) - (declare (ignore database)) - (if val 1 0)) - ;;; Database backend capabilities (defmethod db-type-use-fully-qualified-column-on-drop-index? ((db-type (eql :mssql))) @@ -249,8 +235,9 @@ on schema since that's what tends to be exposed. Some DBs like mssql (%database-list-* database "VIEW" owner)) -(defmethod database-list-attributes ((table string) (database generic-odbc-database) - &key (owner nil)) +(defmethod database-list-attributes ((table %database-identifier) (database generic-odbc-database) + &key (owner nil) + &aux (table (unescaped-database-identifier table))) (declare (ignore owner)) (multiple-value-bind (rows col-names) (funcall (list-all-table-columns-fn database) table @@ -260,8 +247,11 @@ on schema since that's what tends to be exposed. Some DBs like mssql (loop for row in rows collect (fourth row)))) -(defmethod database-attribute-type ((attribute string) (table string) (database generic-odbc-database) - &key (owner nil)) +(defmethod database-attribute-type ((attribute %database-identifier) (table %database-identifier) + (database generic-odbc-database) + &key (owner nil) + &aux (table (unescaped-database-identifier table)) + (attribute (unescaped-database-identifier attribute))) (declare (ignore owner)) (multiple-value-bind (rows col-names) (funcall (list-all-table-columns-fn database) table