Re: Trouble with floats in Postgresql

Andras Simon <[email protected]> Sat, 6 May 2006 11:41:05 +0200 (CEST)
Newsgroups gmane.lisp.clsql.devel
Message-ID <[email protected]>

On Sat, 6 May 2006, Friedrich Dominicus wrote:

> See the following code:
>
> (def-view-class t1 ()
>       ((val :type float :initform 0.16 :accessor val)))
>
> Create an object of that type and safe it in postgres.
> (setf *tobj* (make-instance 't1))
> #<T1 {10032C6201}>
> DB> (update-records-from-instance *tobj*)
> ; No value
>
> It has been inserted:
>
> elect * from t1;
>  val
> ------
>  0.16
>  0.16
> (2 Zeilen)
>
> try to fetch an object of this type:
> (setf *tobj2* (car (select 't1 :flatp t)))
> #<T1 {1003084881}>
>
> check the value:
> (val *tobj2*)
> 0.0d0
>
> ?
>
> So what's going on here. Wrong type? Bug?

What version of PG and CLSQL are you using? With 7.4.11/3.5.6
I can't reproduce this.

CL-USER> (def-view-class t1 ()
      ((val :type float :initform 0.16 :accessor val)))
#<CLSQL-SYS::STANDARD-DB-CLASS T1>
CL-USER> (create-view-from-class 't1)
;; 2006-05-06 10:30:29,,0 localhost/proba/simon => CREATE TABLE t1 (val FLOAT)
; No value
CL-USER> (make-instance 't1)
#<T1 @ #x719a2ec2>
CL-USER> (update-records-from-instance *)
; No value
CL-USER> (car (select 't1 :flatp t))
#<T1 @ #x71abf5ba>
CL-USER> (val *)
0.16d0
CL-USER>

Andras