From: <br...@us...> - 2006-03-11 20:32:04
|
Update of /cvsroot/htoolkit/HSQL/HSQL/Database/HSQL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2890/HSQL/Database/HSQL Modified Files: Types.hs Log Message: The current CVS version cannot convert fields of type SqlText to Haskell Int values. This fixes this problem by calling the default version of fromSqlCStringLen if the field type is such that the value cannot be converted directly. Converting from SqlText to Int is essential for the sqlite drivers, as they return all fields as SqlText. Index: Types.hs =================================================================== RCS file: /cvsroot/htoolkit/HSQL/HSQL/Database/HSQL/Types.hs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Types.hs 9 Jan 2006 14:49:23 -0000 1.9 --- Types.hs 11 Mar 2006 20:32:00 -0000 1.10 *************** *** 151,162 **** -- 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 fromSqlValue :: SqlType -> String -> Maybe a toSqlValue :: a -> String --- 151,165 ---- -- Default version uses fromSqlValue. fromSqlCStringLen :: FieldDef -> CString -> Int -> IO a ! 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 |