Adding an oodml read-sql-value case for double-float
authorNathan Bird <nathan@acceleration.net>
Mon, 1 Mar 2010 20:17:55 +0000 (15:17 -0500)
committerNathan Bird <nathan@acceleration.net>
Tue, 2 Mar 2010 23:16:45 +0000 (18:16 -0500)
sql/oodml.lisp

index 9dc7b0fd0c92bbe2391619e01608ff741f56cd08..5cf86230dfdab18cc4018ee9793ea4007bc6e7be 100644 (file)
   (declare (ignore database db-type))
   ;; writing 1.0 writes 1, so we we *really* want a float, must do (float ...)
   (etypecase val
-    (string
-     (float (read-from-string val)))
-    (float
-     val)))
+    (string (float (read-from-string val)))
+    (float val)))
+
+(defmethod read-sql-value (val (type (eql 'double-float)) database db-type)
+  (declare (ignore database db-type))
+  ;; writing 1.0 writes 1, so if we *really* want a float, must do (float ...)
+  (etypecase val
+    (string (float
+            (let ((*read-default-float-format* 'double-float))
+              (read-from-string val))
+            1.0d0))
+    (double-float val)
+    (float (coerce val 'double-float))))
 
 (defmethod read-sql-value (val (type (eql 'boolean)) database db-type)
   (declare (ignore database db-type))