From: <br...@us...> - 2004-04-27 19:27:20
|
Update of /cvsroot/htoolkit/HSQL/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13819/src Modified Files: HSQL.hsc Log Message: getFieldValueMB now falls back to fromSqlValue if from fromNonNullSqlCStringLen returns Nothing. Added rules for using SqlDouble as Int, Int64 and Integer since at least MySQL sets the type of sums on INT columns to SqlDouble. It makes sense for the user to be able to treat a sum of integers as an integer. Index: HSQL.hsc =================================================================== RCS file: /cvsroot/htoolkit/HSQL/src/HSQL.hsc,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** HSQL.hsc 31 Mar 2004 16:12:46 -0000 1.12 --- HSQL.hsc 27 Apr 2004 19:27:12 -0000 1.13 *************** *** 210,213 **** --- 210,214 ---- fromSqlValue SqlSmallInt s = Just (read s) fromSqlValue SqlBigInt s = Just (read s) + fromSqlValue SqlDouble s = Just (truncate (read s :: Double)) fromSqlValue _ _ = Nothing *************** *** 233,236 **** --- 234,238 ---- fromSqlValue SqlSmallInt s = Just (read s) fromSqlValue SqlBigInt s = Just (read s) + fromSqlValue SqlDouble s = Just (truncate (read s :: Double)) fromSqlValue _ s = Nothing *************** *** 243,246 **** --- 245,249 ---- fromSqlValue SqlSmallInt s = Just (read s) fromSqlValue SqlBigInt s = Just (read s) + fromSqlValue SqlDouble s = Just (truncate (read s :: Double)) fromSqlValue _ _ = Nothing *************** *** 528,534 **** -> IO (Maybe a) -- ^ Field value or Nothing getFieldValueMB stmt name = checkHandle (stmtClosed stmt) $ ! stmtGetCol stmt colNumber (name,sqlType,nullable) fromNonNullSqlCStringLen where (sqlType,nullable,colNumber) = findFieldInfo name (stmtFields stmt) 0 -- | Retrieves the value of field with the specified name. --- 531,544 ---- -> IO (Maybe a) -- ^ Field value or Nothing getFieldValueMB stmt name = checkHandle (stmtClosed stmt) $ ! stmtGetCol stmt colNumber (name,sqlType,nullable) fromCStr where (sqlType,nullable,colNumber) = findFieldInfo name (stmtFields stmt) 0 + fromCStr t c l = do m <- fromNonNullSqlCStringLen t c l + case m of + Just _ -> return m + Nothing -> + do str <- peekCStringLen (c, l) + return (fromSqlValue t str) + -- | Retrieves the value of field with the specified name. |