3

First of all, I'm a Haskell novice who took the big leap of using Haskell now on a first real "Haskell project". In short it's about gathering schema information from different data sources.

I decided to use HDBC with ODBC but I'm getting this unexpected exception. To reproduce:

import Database.HDBC
import Database.HDBC.ODBC

main :: IO ()
main = do
    ioc <- connectODBC "Driver={MySQL};Port=3306;Database=northwind;User=root;Host=localhost"
    x <- describeTable ioc "Categories"
    putStrLn $ show (x !! 3)

When execute this exception occurs:

$ runghc problem-hdbc.hs 
problem-hdbc.hs: Convertible: error converting source data -1 of type Int32 to type Word64: Input value outside of bounds: (0,18446744073709551615)

The relevant database is Microsoft's sample database Northwind. The third column in the table Categories has type longblob.

I can see that show is printing colSize, which is of type Maybe Int. What I don't understand is why ODBC prefers throwing an exception over returning Nothing for colSize.

This leads me to several questions:

  • Is this a bug?
  • If not, what can I do to get around this?
  • What are the best practices when working with Convertible?
Chirs
  • 567
  • 2
  • 15

0 Answers0