[Haskell-cafe] Takusen, postgres and boolean fields

Alistair Bayley alistair at abayley.org
Sat Apr 25 17:13:36 EDT 2009


2009/4/25 Sasha Shipka <xaotuk at gmail.com>:
> When I did SELECT statement I handled boolean field as String, and
> convert it to Bool.
> However when I did update or insert, I must bind those values, then
> takusen calls foreign postgres library and function with "?" and
> values of proper type. So I cannot use neither Bool neither String in
> bindP.
>
> Instead of binding, I've used ugly hack :
> "update some_table set some_boolean_field = ? ..." [bindP True, ...]
> is replaced with
> (printf "update some_table set some_boolean_field = '%s' ... " "t") [...]
> I really hate it and I hope there is better way to do it.

It should be pretty simple to add Bool instances to the class that
handles bind variable marshalling. I'll look into it on Monday. As a
workaround for now, can you use the CAST sql function to convert text
to bool values in Postgres?

Alistair


More information about the Haskell-Cafe mailing list