From: Russ Tyndall Date: Mon, 23 Mar 2015 20:49:10 +0000 (-0400) Subject: Fixed error in read-sql-value that was throwing no next-method errors X-Git-Tag: v6.7.0~11 X-Git-Url: http://git.kpe.io/?p=clsql.git;a=commitdiff_plain;h=f2e97f7b39c1cf82b6f3d1cec9362e551761549e Fixed error in read-sql-value that was throwing no next-method errors * Changed read-sql-value to throw continuable sql-value-conversion-error From the mailing list - thanks Mariano Montone --- diff --git a/LATEST-TEST-RESULTS b/LATEST-TEST-RESULTS index 91103fb..72725ce 100644 --- a/LATEST-TEST-RESULTS +++ b/LATEST-TEST-RESULTS @@ -1,4 +1,4 @@ -Note from Russ Tyndall 2013-01-30 : +Note from Russ Tyndall 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: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/sql/conditions.lisp b/sql/conditions.lisp index 1969b96..e198052 100644 --- a/sql/conditions.lisp +++ b/sql/conditions.lisp @@ -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)) diff --git a/sql/oodml.lisp b/sql/oodml.lisp index 169fa89..5a966e7 100644 --- a/sql/oodml.lisp +++ b/sql/oodml.lisp @@ -657,9 +657,13 @@ (number (not (zerop val)))))) ((wall-time duration) (parse-timestring val)) (date (parse-datestring val)) - (t (call-next-method)))) + (list (let ((*read-eval* nil)) + (read-from-string val))) + (t (error-converting-value val type database)))) (t (typecase val - (string (read-from-string val)) + (string + (let ((*read-eval* nil)) + (read-from-string val))) (t (error-converting-value val type database)))))) ;; ------------------------------------------------------------ diff --git a/tests/test-init.lisp b/tests/test-init.lisp index d1de92e..8312784 100644 --- a/tests/test-init.lisp +++ b/tests/test-init.lisp @@ -216,7 +216,9 @@ (%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)) diff --git a/tests/test-oodml.lisp b/tests/test-oodml.lisp index 042fd48..6278d73 100644 --- a/tests/test-oodml.lisp +++ b/tests/test-oodml.lisp @@ -17,6 +17,13 @@ (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* '( @@ -40,13 +47,32 @@ :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*