X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=sql%2Fusql.cl;h=432a80347ba1eddc4493c067297f424f836752bf;hb=549597d34c262fb744e50f5437f1e2da6f5b9739;hp=9d96874f2033fc514db01739bfb9b941bbee38e3;hpb=d6dde8b6ee55d893a6a1f5ac2392ded90a51953b;p=clsql.git diff --git a/sql/usql.cl b/sql/usql.cl index 9d96874..432a803 100644 --- a/sql/usql.cl +++ b/sql/usql.cl @@ -8,7 +8,7 @@ ;;;; Programmers: Kevin M. Rosenberg and onShore Development Inc ;;;; Date Started: Mar 2002 ;;;; -;;;; $Id: usql.cl,v 1.2 2002/04/03 17:58:23 kevin Exp $ +;;;; $Id: usql.cl,v 1.8 2002/05/19 16:26:06 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; and onShore Development Inc @@ -57,6 +57,9 @@ specifies the database to operation on, defaulting to (error "(rename-attribute ~a ~a ~a ~a) is not implemented" table oldatt newname database)) +(defclass %sql-expression () + ()) + ;; For SQL Identifiers of generic type (defclass sql-ident (%sql-expression) ((name @@ -71,22 +74,6 @@ specifies the database to operation on, defaulting to `(make-instance 'sql-ident :name ',name))) -;; KMR -- change aref to more specific char -(defun sql-escape (identifier) - (let* ((unescaped (etypecase identifier - (symbol (symbol-name identifier)) - (string identifier))) - (escaped (make-string (length unescaped)))) - (dotimes (i (length unescaped)) - (setf (char escaped i) - (cond ((equal (char unescaped i) #\-) - #\_) - ;; ... - (t - (char unescaped i))))) - escaped)) - - (defun create-sequence (name &key (database *default-database*)) (database-create-sequence name database)) @@ -96,14 +83,6 @@ specifies the database to operation on, defaulting to (defun sequence-next (name &key (database *default-database*)) (database-sequence-next name database)) -#+ignore -(defclass sql-typecast-exp (sql-value-exp) - () - (:documentation - "An SQL typecast expression.") - ) - -#+ignore (defclass sql-value-exp (%sql-expression) ((modifier :initarg :modifier @@ -115,22 +94,40 @@ specifies the database to operation on, defaulting to "An SQL value expression.") ) +(defclass sql-typecast-exp (sql-value-exp) + () + (:documentation + "An SQL typecast expression.") + ) (defvar +null-string+ "NULL") (defvar *sql-stream* nil "stream which accumulates SQL output") -(defclass %sql-expression () - ()) - (defmethod output-sql ((expr %sql-expression) &optional (database *default-database*)) (declare (ignore database)) (write-string +null-string+ *sql-stream*)) -#+ignore +(defmethod sql-output ((expr t)) + (declare (ignore expr)) + "") + (defmethod print-object ((self %sql-expression) stream) (print-unreadable-object (self stream :type t) (write-string (sql-output self) stream))) + +;; Methods for translating high-level table classes to low-level functions + +(defmethod database-list-attributes ((table sql-ident) database) + (database-list-attributes (string-downcase + (symbol-name (slot-value table 'name))) + database) + ) + +(defmethod database-attribute-type (attribute (table sql-ident) database) + (database-attribute-type attribute (string-downcase + (symbol-name (slot-value table 'name))) + database))