Re: Type BOOLEAN

Kevin Rosenberg <kevin-HJRc7zDS/[email protected]>
Newsgroups gmane.lisp.clsql.devel
Message-ID <[email protected]>
Edi Weitz wrote:
> Oops, I didn't expect it to be that complicated, I mostly use
> PostgreSQL. Yes, if I were to decide I'd be happy if
> GENERALIZED-BOOLEAN were treated like BOOLEAN is treated now. I
> usually like it if the data Lisp writes to the SQL database is
> accessible by other languages without the need for complicated
> translations.

Okay. PostgreSQL (through ODBC) is one of the tricky boolean
translations. Though the direct postgresql API returns 'f' or 't' for
boolean slots, the psqlodbc driver returns '0' or '1'.

>From sql/generic-odbc.lisp:.

(defmethod read-sql-value (val (type (eql 'boolean))
                           (database generic-odbc-database)
                           (db-type (eql :postgresql)))
  (if (string= "0" val) nil t))
 
   
I'll go ahead and add the generalized-boolean type. This addition does
seem to beg for subclassing on the type specifier. But, I don't think
the code should be refactored just for this one duplicate type which
duplicates the read/write behavior of a different type.

-- 
Kevin Rosenberg
kevin-HJRc7zDS/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.