merging in master from kpe.io
authorRuss Tyndall <russ@acceleration.net>
Fri, 9 Oct 2015 15:30:40 +0000 (11:30 -0400)
committerRuss Tyndall <russ@acceleration.net>
Fri, 9 Oct 2015 15:30:40 +0000 (11:30 -0400)
ChangeLog
LATEST-TEST-RESULTS
clsql.asd
sql/conditions.lisp
sql/db-interface.lisp
sql/expressions.lisp
sql/oodml.lisp
sql/operations.lisp
sql/package.lisp
tests/test-init.lisp
tests/test-oodml.lisp

index 86362c5e6fd31d0439861650abf7d424664634fd..ccc8afcf33a6ca829802594f80b17fab9bb2e79e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,33 @@
+
 2015-08-12 Kevin Rosenberg <kevin@rosenberg.net>
        * Version 6.6.3 release
        * db-oracle/oracle-sql.lisp: Patch for PostgreSQL socket interface
        for unicode characters. Thanks to Jason Melbye.
+       
+2015-06-02 Daniel KochmaƄski <dkochmanski@turtle-solutions.eu>
+       * clsql.asd, sql/package.lisp: Add ECL compatibility fixes
+       * sql/db-interface.lisp: Fix declaration typo
+
+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-30 Kevin Rosenberg <kevin@rosenberg.net>
        * Version 6.6.2 release
        * db-oracle/oracle-sql.lisp: Remove extra hyphen, thanks to
        Thomas Vossen
+       
+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
+       sql-value-conversion-error
+       * default read-sql-value for list
+       * tests for sql-value-conversion-errors and list
+
+2015-03-18 Russ Tyndall <russ@acceleration.net>
+       * {uffi,db-mysql}/Makefile: remove -pie build hardening for
+       which caused load issues for Linux Mint
 
 2015-03-18 Kevin Rosenberg <kevin@rosenberg.net>
        * Version 6.6.1 release
        * Version 6.6.0 release
        * {uffi,db-mysql}/Makefile: Add build hardening for Debian
 
-2014-02-24 Russ Tyndall <russ@acceleration.net>
+2015-02-24 Russ Tyndall <russ@acceleration.net>
        * mysql-sql.lisp
        an error in type declarations generating a compilation warning
        was being treated as an error in recent SBCLs, fixed the type
        warning by correcting the type (still a ton of compliation
        notes)
 
-2014-02-23 Russ Tyndall <russ@acceleration.net>
+2015-02-23 Russ Tyndall <russ@acceleration.net>
        * sql/metaclasses.lisp
        made reinitialize-instance return the instance passed to it as
        SBCL now expected (mentioned on the SBCL-devel mailing list by
index 91103fb51177d24570dd1822c910cfced4137882..72725ce9d9e32d178e8a651e7fa6b7330babf137 100644 (file)
@@ -1,4 +1,4 @@
-Note from Russ Tyndall <russ@acceleration.net> 2013-01-30 :
+Note from Russ Tyndall <russ@acceleration.net> 2015-03-23 :
 
 This is the current results of running the test suite against all the database
 backends I have accessible, on SBCL / UBUNTU64bit.  It would be great to
@@ -7,20 +7,24 @@ tests so that all pass.  In the interim, I would like know that I am not
 increasing the number of failing tests
 
 :mysql
-1 out of 301 total tests failed: :FDDL/CACHE-TABLE-QUERIES/1.
+No tests failed.
+18 of 310 Tests skipped
 
 :odbc MSSQL2000/5
-1 out of 298 total tests failed: :FDDL/CACHE-TABLE-QUERIES/1.
+No tests failed.
+22 of 306 Tests skipped:
 
 :odbc postgres
-2 out of 311 total tests failed: :FDML/SELECT/36, :FDDL/CACHE-TABLE-QUERIES/1.
+*couldnt get them to run - foreign lib problems*
 
 :postgres-socket :postgres-socket-3
-5 out of 300 total tests failed: :TIME/PG/OODML/USEC, :TIME/PG/OODML/NO-USEC, 
-   :TIME/PG/FDML/USEC, :FDML/SELECT/36, :FDDL/CACHE-TABLE-QUERIES/1.
+4 out of 308 total tests failed: :TIME/PG/OODML/USEC, :TIME/PG/OODML/NO-USEC, 
+   :TIME/PG/FDML/USEC, :FDML/SELECT/36.
+20 of 308 Tests skipped:
 
 :sqlite3
-1 out of 300 total tests failed: :FDDL/INDEX/3.
+1 out of 308 total tests failed: :FDDL/INDEX/3.
+20 of 308 Tests skipped:
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
index 5d9adf219577dd1fb0a6f2c36c64eacab78a0c5d..74afd3b6b89c22f91536fa15d7229c4ca78c2e82 100644 (file)
--- a/clsql.asd
+++ b/clsql.asd
@@ -101,7 +101,7 @@ oriented interface."
   (operate 'test-op 'clsql-tests :force t))
 
 (defmethod perform :after ((o load-op) (c (eql (find-system 'clsql))))
-  (let* ((init-var (uffi:getenv "CLSQLINIT"))
+  (let* ((init-var (uffi::getenv "CLSQLINIT"))
          (init-file (or (when init-var (probe-file init-var))
                         (probe-file
                          (concatenate 'string
index 1969b962ae28728e565ea2d6a11fd03f04c49acc..e19805248bd5e6f9601a98db29a3e76157741238 100644 (file)
@@ -151,8 +151,9 @@ connection is no longer usable."))
 
 (defun error-converting-value (val type &optional (database *default-database*))
   (restart-case 
-      (error 'sql-value-conversion-error
-             :expected-type type :value val :database database)
+      (error (make-condition
+              'sql-value-conversion-error
+              :expected-type type :value val :database database))
     (continue ()
       :report "Continue using the unconverted value"
       (values val t))
index 5cdb719f3ea00cdc4915701fff2abec177aaff49..3454a84ee8d992372e07ba3abf7a7c3d07258a1c 100644 (file)
@@ -380,8 +380,8 @@ of TYPE_NAME (keyword) PRECISION SCALE NULLABLE.")
 
 (defgeneric db-type-has-auto-increment? (db-type)
   (:method (db-type)
-    (declare (ignore db-type)
-            nil))
+    (declare (ignore db-type))
+            nil)
   (:documentation "NIL [default] if database-type supports auto-incrementing columns."))
 
 ;;; Large objects support (Marc Battyani)
index 4c57bc3e86f71ae6f97a174587bb93b546a034fb..4f0baf1230b0ab32353dc69026645306adae11e0 100644 (file)
           (remove-duplicates tabs :test #'database-identifier-equal))
         nil)))
 
-
-
 (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))
 
+
+(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 169fa89d70d6f0fe17e834749e9a27f337cfe2f8..0e4810b3ad8b63bae2228c0fc3a97fc021b7bc88 100644 (file)
   (declare (ignore db-type))
   (cond
     ;; null value or type
-    ((or (equalp "nil" val) (eql 'null val)) nil) 
-    
+    ((or (null val)
+         (equalp "nil" val)
+         (eql 'null val)
+         (eql 'null type))
+     nil)
+
     ;; no specified type or already the right type
     ((or (null type)
          (ignore-errors (typep val type)))
      val)
 
     ;; actually convert
-    (t 
+    (t
      (let ((res (handler-bind
                     ;; all errors should be converted to sql-value-conversion-error
                     ((error (lambda (c)
-                              (when *debugger-hook*
-                                (invoke-debugger c))
                               (unless (typep c 'sql-value-conversion-error)
+                                ;; this was blowing up the tests till I
+                                ;; unbound *debugger-hook* not sure the answer,
+                                ;; as this is also imensely useful in actually
+                                ;; finding bugs below this point
+                                (when *debugger-hook* (invoke-debugger c))
                                 (error-converting-value val type database)))))
                   (call-next-method))))
        ;; if we didnt get the right type after converting, we should probably
        ;; error right away
-       (maybe-error-converting-value
-        res val type database)))))
+       (maybe-error-converting-value res val type database)))))
 
 (defmethod read-sql-value (val type database db-type)
+  "read a sql value, from :around read-eval is disabled read numbers in base 10"
   ;; errors, nulls and preconverted types are already handled in around
   (typecase type
     (symbol
                              (double-float 'double-float))))
                      (read-from-string val)))
            ;; maybe wrong type of float
-           (float val)) 
+           (float val))
          (if (eql type 'double-float) 1.0d0 1.0s0)))
        (number (read-from-string val))
        ((boolean generalized-boolean)
               (number (not (zerop val))))))
        ((wall-time duration) (parse-timestring val))
        (date (parse-datestring val))
-       (t (call-next-method))))
+       (list (read-from-string val))
+       (t (error-converting-value val type database))))
     (t (typecase val
          (string (read-from-string val))
          (t (error-converting-value val type database))))))
index 37d751e0f90abc09189de627df483e1aab454119..faa22b5af7a8788aea28ef66d14b7b5619edf734 100644 (file)
@@ -46,6 +46,9 @@
   (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))
index 470be84e22d06ec30ea0dac20c305ac861f3f3c9..8915b06781011292d8fdbdbe7ca5f452c96ffb33 100644 (file)
@@ -37,6 +37,7 @@
           #+clsql-cmucl-mop #:mop
           #+allegro #:mop
           #+clisp #:clos
+          #+ecl #:mop
           #+lispworks #:clos
           #+scl #:clos
           #+openmcl #:openmcl-mop)
index d1de92e94668eda0afacc5dc61e6148c2a2472af..8312784216c8fd84f50f4575f255bab0de691363 100644 (file)
 
          (%do-tests test-forms db-type)
 
-           (format *report-stream* "~&Tests skipped:")
+         (format *report-stream* "~&~D of ~D Tests skipped:"
+                 (length skip-tests)
+                 (length test-forms))
            (if skip-tests
                (let ((max-test-name (length (symbol-name (caar skip-tests)))))
                  (dolist (skipped (cdr skip-tests))
index 042fd48b6d71bb39cf8cb720ad60ae159dc76d85..6278d73cd64e40f78bd2ef415072328127a3b69f 100644 (file)
 
 (clsql-sys:file-enable-sql-reader-syntax)
 
+(defmacro has-sql-value-conversion-error (() &body body)
+  `(let (*debugger-hook*)
+    (handler-case
+        (progn ,@body nil)
+      (clsql-sys::sql-value-conversion-error (c)
+        (declare (ignore c))
+        t))))
 
 (setq *rt-oodml*
       '(
  :foo)
 
 (deftest :oodml/read-symbol-value/4-keyword-error
- (handler-case
-     (clsql-sys::read-sql-value
-      (clsql-sys::database-output-sql-as-type 'keyword 'foo nil nil)
-      'keyword nil nil)
-   (clsql-sys::sql-value-conversion-error (c) (declare (ignore c))
-     :error))
- :error)
+ (has-sql-value-conversion-error ()
+   (clsql-sys::read-sql-value
+    (clsql-sys::database-output-sql-as-type 'keyword 'foo nil nil)
+    'keyword nil nil))
+ T)
+
+(deftest :oodml/read-symbol-value/5-unknown-type-error-1
+ (has-sql-value-conversion-error ()
+   (clsql-sys::read-sql-value
+    (clsql-sys::database-output-sql-as-type 'bloop 'foo nil nil)
+    'bloop nil nil))
+ t)
+
+(deftest :oodml/read-symbol-value/6-unknown-type-error-2
+ (has-sql-value-conversion-error ()
+   (clsql-sys::read-sql-value
+    (clsql-sys::database-output-sql-as-type 'bloop 'foo nil nil)
+    '(or integer float) nil nil))
+ t)
+
+(deftest :oodml/read-symbol-value/read-list
+ (clsql-sys::read-sql-value
+  (clsql-sys::database-output-sql-as-type
+   'list '(("status" "new" "open")) nil nil)
+  'list nil nil)
+ (("status" "new" "open")))
 
 (deftest :oodml/select/1
     (with-dataset *ds-employees*