Update of /cvsroot/htoolkit/HSQL/HSQL/Database/HSQL
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7000/HSQL/Database/HSQL
Modified Files:
Types.hs
Log Message:
Another way to handle null values in HSQL. Not tested yet.
Index: Types.hs
===================================================================
RCS file: /cvsroot/htoolkit/HSQL/HSQL/Database/HSQL/Types.hs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Types.hs 14 Jun 2005 09:38:47 -0000 1.2
--- Types.hs 12 Dec 2005 15:21:55 -0000 1.3
***************
*** 3,7 ****
--- 3,9 ----
import Control.Concurrent.MVar
+ import Control.Exception
import Data.Dynamic
+ import Foreign
import Foreign.C
***************
*** 130,134 ****
, stmtClose :: IO ()
, stmtFetch :: IO Bool
! , stmtGetCol :: forall a . Int -> FieldDef -> (SqlType -> CString -> Int -> IO (Maybe a)) -> IO (Maybe a)
, stmtFields :: [FieldDef]
, stmtClosed :: MVar Bool
--- 132,136 ----
, stmtClose :: IO ()
, stmtFetch :: IO Bool
! , stmtGetCol :: forall a . Int -> FieldDef -> (FieldDef -> CString -> Int -> IO a) -> IO a
, stmtFields :: [FieldDef]
, stmtClosed :: MVar Bool
***************
*** 139,146 ****
-- This allows for faster conversion for eq. integral numeric types, etc.
-- Default version uses fromSqlValue.
! fromNonNullSqlCStringLen :: SqlType -> CString -> Int -> IO (Maybe a)
! fromNonNullSqlCStringLen sqlType cstr cstrLen = do
! str <- peekCStringLen (cstr, cstrLen)
! return (fromSqlValue sqlType str)
fromSqlValue :: SqlType -> String -> Maybe a
--- 141,152 ----
-- 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
fromSqlValue :: SqlType -> String -> Maybe a
|