Guard against already converted values in read-sql-value
authorNathan Bird <nathan@acceleration.net>
Mon, 20 Jul 2009 20:18:12 +0000 (16:18 -0400)
committerNathan Bird <nathan@acceleration.net>
Tue, 2 Mar 2010 23:16:45 +0000 (18:16 -0500)
Sometimes select has already done the conversion to native lisp format,
we then don't need to do anything here, but was causing an error as
read-from-string on a value that isn't a string isn't allowed.

sql/oodml.lisp

index 634acc859f9fa5e3e14f459d2ef77bd67c697ebf..9dc7b0fd0c92bbe2391619e01608ff741f56cd08 100644 (file)
        (format nil "~F" val))))
 
 (defmethod read-sql-value (val type database db-type)
-  (declare (ignore type database db-type))
-  (read-from-string val))
+  (declare (ignore database db-type))
+  (cond
+    ((null type) val) ;;we have no desired type, just give the value
+    ((typep val type) val) ;;check that it hasn't already been converted.
+    ((typep val 'string) (read-from-string val)) ;;maybe read will just take care of it?
+    (T (error "Unable to read-sql-value ~a as type ~a" val type))))
 
 (defmethod read-sql-value (val (type (eql 'string)) database db-type)
   (declare (ignore database db-type))