Parsing for double precision not working yet

Daniel Brunner daniel at dbrunner.de
Wed Nov 27 14:01:51 UTC 2013


[NB: Marjin, I already posted this issue on Github]

Hello!

There is a problem with columns with double precision.

Test case:
--8<--
(pomo:query "create table ftest (value double precision)")
(pomo:query "insert into ftest values ($1)" (coerce 100.10 'double-float))
--8<--

This fails with:
--8<--
Database error 22P02: invalid input syntax for type double precision:
"100.0999984741211D0"
   [Condition of type CL-POSTGRES-ERROR:DATA-EXCEPTION]
--8<--

A short patch in cl-postgres/sql-string.lisp could solve that problem:

--8<--
diff --git a/cl-postgres/sql-string.lisp b/cl-postgres/sql-string.lisp
index 3157d30..4dff4be 100644
--- a/cl-postgres/sql-string.lisp
+++ b/cl-postgres/sql-string.lisp
@@ -84,6 +84,8 @@ whether the string should be escaped before being put
into a query.")
     (princ-to-string arg))
   (:method ((arg float))
     (format nil "~f" arg))
+  (:method ((arg double-float))
+    (format nil "~,,,,,,'EE" arg))
   (:method ((arg ratio))
     ;; Possible optimization: we could probably build up the same
binary structure postgres
--8<--


Best wishes,
Daniel



More information about the postmodern-devel mailing list