projects
/
clsql.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r10618: new file
[clsql.git]
/
sql
/
expressions.lisp
diff --git
a/sql/expressions.lisp
b/sql/expressions.lisp
index 7f0ad1f82ff601a6556a8d45080fcb481494ba27..2098cf3e1d33e4cc287f4e8f91db01cebce191b9 100644
(file)
--- a/
sql/expressions.lisp
+++ b/
sql/expressions.lisp
@@
-67,7
+67,8
@@
(defmethod print-object ((self %sql-expression) stream)
(print-unreadable-object
(self stream :type t)
(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
;; For straight up strings
@@
-91,7
+92,8
@@
(defmethod print-object ((ident sql) stream)
(format stream "#<~S \"~A\">"
(type-of ident)
(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
;; For SQL Identifiers of generic type
@@
-354,7
+356,7
@@
(defmethod collect-table-refs ((sql sql-function-exp))
(let ((tabs nil))
(defmethod collect-table-refs ((sql sql-function-exp))
(let ((tabs nil))
- (dolist (exp (slot-value sql '
component
s))
+ (dolist (exp (slot-value sql '
arg
s))
(let ((refs (collect-table-refs exp)))
(if refs (setf tabs (append refs tabs)))))
(remove-duplicates tabs
(let ((refs (collect-table-refs exp)))
(if refs (setf tabs (append refs tabs)))))
(remove-duplicates tabs
@@
-692,7
+694,7
@@
uninclusive, and the args from that keyword to the end."
stmt
(write-string "DELETE FROM " *sql-stream*)
(typecase from
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*)
(t (output-sql from database)))
(when where
(write-string " WHERE " *sql-stream*)
@@
-828,9
+830,8
@@
uninclusive, and the args from that keyword to the end."
;;
(defmethod database-output-sql ((str string) database)
;;
(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)))
(let ((len (length str)))
(declare (type fixnum len))
(cond ((zerop len)
(let ((len (length str)))
(declare (type fixnum len))
(cond ((zerop len)
@@
-840,7
+841,8
@@
uninclusive, and the args from that keyword to the end."
(concatenate 'string "'" str "'"))
(t
(let ((buf (make-string (+ (* len 2) 2) :initial-element #\')))
(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))
(j 1 (incf j)))
((= i len) (subseq buf 0 (1+ j)))
(declare (type fixnum i j))
@@
-850,7
+852,11
@@
uninclusive, and the args from that keyword to the end."
(setf (aref buf j) #\')
(incf j)
(setf (aref buf j) #\'))
(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) #\\))
(setf (aref buf j) #\\)
(incf j)
(setf (aref buf j) #\\))