Add postgresql escape string expression/operator
authorRuss Tyndall <russ@acceleration.net>
Mon, 6 Apr 2015 14:31:08 +0000 (10:31 -0400)
committerRuss Tyndall <russ@acceleration.net>
Mon, 6 Apr 2015 14:31:08 +0000 (10:31 -0400)
ChangeLog
sql/expressions.lisp
sql/operations.lisp

index 45fa7d754eb3c5785fdddf0083666a7cfa80c991..947d2eb20c8250dfb5057323c00fb400be83e43b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-04-06 Russ Tyndall <russ@acceleration.net>
+       * sql/operations, sql/expressions: add postgresql E-string
+       operator / expression.  Needed for correct regex handling
+       EG: [E "some string"]=> E'some string'
+
 2015-03-24 Russ Tyndall <russ@acceleration.net>
        * sql/oodml.lisp: fixed call-next-method in the base of
        read-sql-value and replaced with a continuable
 2015-03-24 Russ Tyndall <russ@acceleration.net>
        * sql/oodml.lisp: fixed call-next-method in the base of
        read-sql-value and replaced with a continuable
index 4c57bc3e86f71ae6f97a174587bb93b546a034fb..4f0baf1230b0ab32353dc69026645306adae11e0 100644 (file)
           (remove-duplicates tabs :test #'database-identifier-equal))
         nil)))
 
           (remove-duplicates tabs :test #'database-identifier-equal))
         nil)))
 
-
-
 (defmethod output-sql ((expr sql-value-exp) database)
   (with-slots (modifier components)
     expr
 (defmethod output-sql ((expr sql-value-exp) database)
   (with-slots (modifier components)
     expr
@@ -1234,3 +1232,16 @@ uninclusive, and the args from that keyword to the end."
     returns nil if there are no children"
   (clsql-ors clauses))
 
     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))))
index 37d751e0f90abc09189de627df483e1aab454119..faa22b5af7a8788aea28ef66d14b7b5619edf734 100644 (file)
@@ -46,6 +46,9 @@
   (make-instance 'sql-function-exp
                  :name 'all :args rest))
 
   (make-instance 'sql-function-exp
                  :name 'all :args rest))
 
+(defsql sql-e-string (:symbol "E") (&rest rest)
+  (make-instance 'sql-escape-string-exp :string (first rest)))
+
 (defsql sql-not (:symbol "not") (&rest rest)
   (make-instance 'sql-value-exp
                  :modifier 'not :components rest))
 (defsql sql-not (:symbol "not") (&rest rest)
   (make-instance 'sql-value-exp
                  :modifier 'not :components rest))