[Haskell-cafe] HDBC-ODBC and SqlValues

John Goerzen jgoerzen at complete.org
Thu Apr 8 14:24:58 EDT 2010


Tim Docker wrote:
> Jason:
> 
> Thanks for the reply.
> 
>> I suspect the solution is to correctly tell Haskell what type you
>> expect and then hopefully HDBC will do the conversion.  For example,
>> using fromSql:
>> http://software.complete.org/static/hdbc/doc/Database-HDBC.html#v%
>> 3AfromSql
> 
> Yes. I can use fromSql to convert the result back to an appropriate
> numerical type. But internally the numeric data has still been converted
> to an intermediate string representation. I'm wondering if this is
> intentional, and whether it matters.

Yes and no, in that order.

A ByteString is a pretty universal holder for various types of data.  As
someone else pointed out, at query time, we don't really have access to
what type you will eventually want to use it as, and supporting the vast
number of different ways to get things out of databases -- with the
corresponding complexities of how a database driver can convert between
them -- was just not worth it.

It is generally assumed that the end user will be using fromSql anyhow,
so it is not particularly relevant if it's a SqlByteString or a
SqlInteger internally.

-- John


More information about the Haskell-Cafe mailing list