Hi Krasimir, A user of the Debian package of hsql-sqlite3 reported an issue with respect to type information which is ignored in the sqlite3 driver.
I did look at the code a little bit but I do not have enough knowledge about it to see how of if this can be fixed. Maybe you can have a look at the issue reported below and tell if this can be fixed. Greetings Arjan p.s. please keep the [EMAIL PROTECTED] in the To / CC header when responding to keep the Debian bug report up to date -------Doorgestuurd bericht------- Van: Austin Clements <[EMAIL PROTECTED]> Antwoordadres: Austin Clements <[EMAIL PROTECTED]>, [EMAIL PROTECTED] Aan: Debian Bug Tracking System <[EMAIL PROTECTED]> Onderwerp: Bug#468436: libghc6-hsql-sqlite3-dev: Fails to read non-text fields Datum: Thu, 28 Feb 2008 18:11:05 -0500 Package: libghc6-hsql-sqlite3-dev Version: 1.7-1 Severity: important The sqllite driver ignores field type information, reporting all fields as SqlText fields. This was workable in HSQL 1.6, but conflicts with changes in HSQL 1.7, resulting in SQL type cast exceptions when trying to read fields as Int's or Int64's. The bug occurs when calling getFieldValue on an INTEGER field and expecting getFieldValue to yield an Int. For example, > import Database.HSQL.SQLite3 > import System.IO (IOMode(ReadWriteMode)) > > main = test `catchSql` (error . show) > > test = do > c <- connect "test.db" ReadWriteMode > execute c "create table Foo (x INTEGER)" > execute c "insert into Foo values (42)" > s <- query c "select x from Foo" > forEachRow' (\s -> do > v <- getFieldValue s "x" > print (v :: Int)) s In HSQL 1.6, getFieldValue would call getFieldValueMB, which would parse an Int field by first invoking fromNonNullSqlCStringLen in the SqlBind instance for Int. Because the sqlite driver always reported SqlText for sqlType, this would return Nothing, so getFieldValueMB would convert the field to a Haskell String and fall back to fromSqlValue in SqlBind. For SqlText-typed fields, this would simply use the read function. Thus, ultimately, you would get the integral value of the field. In HSQL 1.7, the implementation of getFieldValue no longer falls back to fromSqlValue if fromSqlCStringLen fails. (Indeed, fromSqlCStringLen now fails with an exception instead of by returning Nothing.) Thus, when fromSqlCStringLen in the SqlBind Int instance is passed the SqlText-typed field, it fails with a SQL type cast exception. There are a few potential ways to fix this bug. Probably the ideal way is to fix the sqlite driver to return the correct field types (which are already available in the results of the pragma call). Alternatively, the old behavior of getFieldValue could be restored, but this would probably be difficult in light of the changes to fromSqlCStringLen and isn't ideal anyways. Better would be to make fromSqlCStringLen and fromSqlValue behave equivalently in instances that provide fromSqlCStringLen, since the intent seems to be that fromSqlCStringLen is merely an optimization of fromSqlValue. -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing') Architecture: i386 (i686) Kernel: Linux 2.6.21-awakening Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash
signature.asc
Description: Dit berichtdeel is digitaal ondertekend