(defmethod print-object ((self %sql-expression) stream)
(print-unreadable-object
(self stream :type t)
- (write-string (sql-output self) stream)))
+ (write-string (sql-output self) stream))
+ self)
;; For straight up strings
(defmethod print-object ((ident sql) stream)
(format stream "#<~S \"~A\">"
(type-of ident)
- (sql-output ident nil)))
+ (sql-output ident nil))
+ ident)
;; For SQL Identifiers of generic type
(defmethod collect-table-refs ((sql sql-function-exp))
(let ((tabs nil))
- (dolist (exp (slot-value sql 'components))
+ (dolist (exp (slot-value sql 'args))
(let ((refs (collect-table-refs exp)))
(if refs (setf tabs (append refs tabs)))))
(remove-duplicates tabs
stmt
(write-string "DELETE FROM " *sql-stream*)
(typecase from
- (symbol (write-string (sql-escape from) *sql-stream*))
+ ((or symbol string) (write-string (sql-escape from) *sql-stream*))
(t (output-sql from database)))
(when where
(write-string " WHERE " *sql-stream*)
;;
(defmethod database-output-sql ((str string) database)
- (declare (ignore database)
- (optimize (speed 3) (safety 1) #+cmu (extensions:inhibit-warnings 3))
- (type (simple-array * (*)) str))
+ (declare (optimize (speed 3) (safety 1)
+ #+cmu (extensions:inhibit-warnings 3))
+ (simple-string str))
(let ((len (length str)))
(declare (type fixnum len))
(cond ((zerop len)
(setf (aref buf j) #\')
(incf j)
(setf (aref buf j) #\'))
- ((char= char #\\)
+ ((and (char= char #\\)
+ ;; MTP: only escape backslash with pgsql/mysql
+ (member (database-underlying-type database)
+ '(:postgresql :mysql)
+ :test #'eq))
(setf (aref buf j) #\\)
(incf j)
(setf (aref buf j) #\\))
(let ((keyword-package (symbol-package :foo)))
(defmethod database-output-sql ((sym symbol) database)
- (convert-to-db-default-case
- (if (equal (symbol-package sym) keyword-package)
- (concatenate 'string "'" (string sym) "'")
- (symbol-name sym))
- database)))
+ (if (null sym)
+ +null-string+
+ (convert-to-db-default-case
+ (if (equal (symbol-package sym) keyword-package)
+ (concatenate 'string "'" (string sym) "'")
+ (symbol-name sym))
+ database))))
(defmethod database-output-sql ((tee (eql t)) database)
(declare (ignore database))