X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=sql%2Fexpressions.lisp;h=1b3b1a486ca2f42ab44f586b4b358d5d7275c9e0;hb=refs%2Fheads%2F6.8.0;hp=10bdb5ec0b2a0dd23e7d85032da5f180e1b45315;hpb=374df8f34a7214e08fc4cfc5d734d024acdbf9ca;p=clsql.git diff --git a/sql/expressions.lisp b/sql/expressions.lisp index 10bdb5e..1b3b1a4 100644 --- a/sql/expressions.lisp +++ b/sql/expressions.lisp @@ -420,13 +420,13 @@ (defmethod output-sql ((expr sql-assignment-exp) database) (with-slots (operator sub-expressions) - expr - (do ((sub sub-expressions (cdr sub))) - ((null (cdr sub)) (output-sql (car sub) database)) - (output-sql (car sub) database) + expr + (output-sql (car sub-expressions) database) + (dolist (sub (cdr sub-expressions)) (write-char #\Space *sql-stream*) (%write-operator operator database) - (write-char #\Space *sql-stream*))) + (write-char #\Space *sql-stream*) + (output-sql sub database))) t) (defclass sql-value-exp (%sql-expression) @@ -450,8 +450,6 @@ (remove-duplicates tabs :test #'database-identifier-equal)) nil))) - - (defmethod output-sql ((expr sql-value-exp) database) (with-slots (modifier components) expr @@ -1011,9 +1009,7 @@ uninclusive, and the args from that keyword to the end." (setf (aref buf j) #\')) ((and (char= char #\\) ;; MTP: only escape backslash with pgsql/mysql - (member (database-underlying-type database) - '(:postgresql :mysql) - :test #'eq)) + (database-escape-backslashes database)) (setf (aref buf j) #\\) (incf j) (setf (aref buf j) #\\)) @@ -1108,7 +1104,9 @@ uninclusive, and the args from that keyword to the end." (ecase (database-underlying-type database) (:mssql "IDENTITY (1,1)") ((:sqlite :sqlite3) "PRIMARY KEY AUTOINCREMENT") - (:mysql "AUTO_INCREMENT"))) + (:mysql "AUTO_INCREMENT") + ;; this is modeled as a datatype instead of a constraint + (:postgresql ""))) ;; everything else just get the name (T (string-upcase (symbol-name constraint))))) @@ -1232,3 +1230,16 @@ uninclusive, and the args from that keyword to the end." returns nil if there are no children" (clsql-ors clauses)) + +(defclass sql-escape-string-exp (%sql-expression) + ((string + :initarg :string + :initform nil)) + (:documentation + "An escaped string string expression (postgresql E'stuff') .")) + +(defmethod output-sql ((exp sql-escape-string-exp) database) + (with-slots (string) exp + (when string + (write-char #\E *sql-stream*) + (output-sql string database))))