Index: HSQL/Database/HSQL.hsc =================================================================== RCS file: /cvsroot/htoolkit/HSQL/HSQL/Database/HSQL.hsc,v retrieving revision 1.16 diff -u -r1.16 HSQL.hsc --- HSQL/Database/HSQL.hsc 9 Jan 2006 14:49:23 -0000 1.16 +++ HSQL/Database/HSQL.hsc 11 Mar 2006 20:27:45 -0000 @@ -239,7 +239,8 @@ sqlType==SqlTinyInt || sqlType==SqlSmallInt|| sqlType==SqlBigInt = c_atoi cstr - | otherwise = throwDyn (SqlBadTypeCast name sqlType) + fromSqlCStringLen field cstr cstrLen + = defaultFromSqlCStringLen field cstr cstrLen fromSqlValue SqlInteger s = Just (read s) fromSqlValue SqlMedInt s = Just (read s) @@ -265,7 +266,8 @@ #else c_strtoll cstr nullPtr 10 #endif - | otherwise = throwDyn (SqlBadTypeCast name sqlType) + fromSqlCStringLen field cstr cstrLen + = defaultFromSqlCStringLen field cstr cstrLen fromSqlValue SqlInteger s = Just (read s) fromSqlValue SqlMedInt s = Just (read s) Index: HSQL/Database/HSQL/Types.hs =================================================================== RCS file: /cvsroot/htoolkit/HSQL/HSQL/Database/HSQL/Types.hs,v retrieving revision 1.9 diff -u -r1.9 Types.hs --- HSQL/Database/HSQL/Types.hs 9 Jan 2006 14:49:23 -0000 1.9 +++ HSQL/Database/HSQL/Types.hs 11 Mar 2006 20:27:45 -0000 @@ -150,13 +150,16 @@ -- This allows for faster conversion for eq. integral numeric types, etc. -- Default version uses fromSqlValue. fromSqlCStringLen :: FieldDef -> CString -> Int -> IO a - fromSqlCStringLen (name,sqlType,_) cstr cstrLen - | cstr == nullPtr = throwDyn (SqlFetchNull name) - | otherwise = do - str <- peekCStringLen (cstr, cstrLen) - case fromSqlValue sqlType str of - Nothing -> throwDyn (SqlBadTypeCast name sqlType) - Just v -> return v + fromSqlCStringLen = defaultFromSqlCStringLen fromSqlValue :: SqlType -> String -> Maybe a toSqlValue :: a -> String + +defaultFromSqlCStringLen :: SqlBind a => FieldDef -> CString -> Int -> IO a +defaultFromSqlCStringLen (name,sqlType,_) cstr cstrLen + | cstr == nullPtr = throwDyn (SqlFetchNull name) + | otherwise = do + str <- peekCStringLen (cstr, cstrLen) + case fromSqlValue sqlType str of + Nothing -> throwDyn (SqlBadTypeCast name sqlType) + Just v -> return v