Re: SQL numeric -> CL rational?

Nicolas Neuss <neuss-8Qd08/[email protected]> Tue, 15 Oct 2013 19:28:10 +0200
Newsgroups gmane.lisp.clsql.general
Message-ID <[email protected]>
Russ Tyndall <[email protected]> writes:

> One possible solution to get you running immediately is an (setf
> closer-mop:slot-value-using-class) :after method specialized on your view
> class type (or a new parent class)  method to convert the types of the
> values as they go into the slots.  Alternatively, you could add methods
> that convert after it is read from the database
> (clsql-sys::get-slot-values-from-view,
> clsql-sys::update-slot-from-db-value,
> clsql-sys:update-instance-from-records are probably the relevant methods).
>
> As far as getting the previous behavior.  This could be related to using
> postgresql-socket-3 (if that is the backend you are using), and switching
> to postgresql-socket, or postgresql, could return you the old behavior).
> The postgresql-socket-3 backend uses cl-postgres underneath and does type
> coercion in its own code before clsql sees it.  I don't use the other
> postgres backends much though so I am not sure.
>
> To begin diagnosing this problem better, though I would need to know which
> backend you are using against what version of postgres.
>
> Hope this helps, Cheers,
> Russ Tyndall
> Acceleration.net

Hello Russ,

thank you.  You hit the nail on the head!  Indeed, I have switched some
time ago to the postgresql-socket3 backend (because the other two showed
some other problems I don't remember any more, sorry for that).

I think I will follow your advice and will try to change non-integer
rational values with an :after method.

Thank you,

Nicolas

P.S.: Interestingly, I can find no conclusive answer to which behavior I
      would prefer if I had to design such an interface from scratch...

> On 10/15/2013 9:27 AM, Nicolas Neuss wrote:
>> Hello,
>>
>> I just observe that numbers like 1.5 (of type 'numeric' in my Postgresql
>> database) appear as rationals 3/2 in SELECT queries or VIEW-CLASS
>> objects.
>>
>> Was this changed recently?  If yes, is there a way to revert to the old
>> behavior?  I have an old application which I am reactivating and which
>> breaks at this point, and I am just wondering how I should fix it in the
>> most reasonable way.
>>
>> Thank you,
>>
>> Nicolas