X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=sql%2Fgeneric-odbc.lisp;h=d64db208b1b3a62b190b4773624ab67cd8adb12b;hp=9699d292cb3ef0bca895fbe3e7402078c0e09dd8;hb=f103c1a5416d2f22820d66020e4f9c18c766d894;hpb=73f6c23a39a24d04746b00d8fe3878ca7a6233f1 diff --git a/sql/generic-odbc.lisp b/sql/generic-odbc.lisp index 9699d29..d64db20 100644 --- a/sql/generic-odbc.lisp +++ b/sql/generic-odbc.lisp @@ -1,8 +1,6 @@ ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;;; ************************************************************************* ;;;; -;;;; $Id$ -;;;; ;;;; Generic ODBC layer, used by db-odbc and db-aodbc backends ;;;; ;;;; This file is part of CLSQL. @@ -74,20 +72,20 @@ ;;; Type methods -(defmethod database-get-type-specifier ((type (eql 'wall-time)) args database - (db-type (eql :mssql))) - (declare (ignore args database)) - "DATETIME") - -(defmethod database-get-type-specifier ((type (eql 'boolean)) args database +(defmethod database-get-type-specifier ((type symbol) 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 @@ -96,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))) @@ -247,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 @@ -258,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