r10789: Automated commit for Debian build of clsql upstream-version-3.3.1
[clsql.git] / sql / expressions.lisp
index 96013deaae1a25883dbb497cd7a3e5138907ad57..67fc6fa0b3c40a47312c8fd90e76c791f580e8a3 100644 (file)
     `(make-instance 'sql-ident-table :name ',name :table-alias ',alias)))
 
 (defmethod output-sql ((expr sql-ident-table) database)
-  (with-slots (name alias)
-    expr
-    (if (null alias)
-        (write-string (sql-escape (convert-to-db-default-case (symbol-name name) database)) *sql-stream*)
-        (progn
-          (write-string (sql-escape (convert-to-db-default-case (symbol-name name) database)) *sql-stream*)
-          (write-char #\Space *sql-stream*)
-          (format *sql-stream* "~s" alias))))
+  (with-slots (name alias) expr
+     (let ((namestr (if (symbolp name)
+                        (symbol-name name)
+                      name)))
+       (if (null alias)
+           (write-string
+            (sql-escape (convert-to-db-default-case namestr database))
+            *sql-stream*)
+         (progn
+           (write-string
+            (sql-escape (convert-to-db-default-case namestr database))
+            *sql-stream*)
+           (write-char #\Space *sql-stream*)
+           (format *sql-stream* "~s" alias)))))
   t)
 
 (defmethod output-sql-hash-key ((expr sql-ident-table) database)
     :initform nil))
   (:documentation "An SQL relational expression."))
 
+(defmethod make-load-form ((self sql-relational-exp) &optional environment)
+  (make-load-form-saving-slots self
+                               :slot-names '(operator sub-expressions)
+                               :environment environment))
+
 (defmethod collect-table-refs ((sql sql-relational-exp))
   (let ((tabs nil))
     (dolist (exp (slot-value sql 'sub-expressions))
@@ -831,8 +842,7 @@ uninclusive, and the args from that keyword to the end."
 
 (defmethod database-output-sql ((str string) database)
   (declare (optimize (speed 3) (safety 1)
-                    #+cmu (extensions:inhibit-warnings 3))
-           (simple-string str))
+                    #+cmu (extensions:inhibit-warnings 3)))
   (let ((len (length str)))
     (declare (type fixnum len))
     (cond ((zerop len)
@@ -842,7 +852,8 @@ uninclusive, and the args from that keyword to the end."
            (concatenate 'string "'" str "'"))
           (t
            (let ((buf (make-string (+ (* len 2) 2) :initial-element #\')))
-             (do* ((i 0 (incf i))
+            (declare (simple-string buf))
+            (do* ((i 0 (incf i))
                    (j 1 (incf j)))
                   ((= i len) (subseq buf 0 (1+ j)))
                (declare (type fixnum i j))
@@ -903,6 +914,10 @@ uninclusive, and the args from that keyword to the end."
   (declare (ignore database))
   (db-timestring self))
 
+(defmethod database-output-sql ((self date) database)
+  (declare (ignore database))
+  (db-datestring self))
+
 (defmethod database-output-sql ((self duration) database)
   (declare (ignore database))
   (format nil "'~a'" (duration-timestring self)))