--- haskelldb-hdbc-2.1.0.orig/Database/HaskellDB/HDBC.hs	2010-11-12 02:07:20.000000000 +0900
+++ haskelldb-hdbc-2.1.0/Database/HaskellDB/HDBC.hs	2012-10-10 01:16:46.761751033 +0900
@@ -160,6 +160,9 @@
 
 type HDBCRow = Map String HDBC.SqlValue
 
+normalizeField :: String -> String
+normalizeField =  map toLower
+
 -- | Primitive query
 hdbcPrimQuery :: (GetRec er vr, IConnection conn) => 
 		 conn -- ^ Database connection.
@@ -171,8 +174,13 @@
     do
     stmt <- handleSqlError $ HDBC.prepare conn sql
     handleSqlError $ HDBC.execute stmt []
-    rows <- HDBC.fetchAllRowsMap stmt
-    mapM (getRec hdbcGetInstances rel scheme) rows
+    rows <- fetchLowerAllRowsAL stmt
+    mapM (getRec hdbcGetInstances rel scheme) $ map Map.fromList rows
+  where fetchLowerAllRowsAL sth =
+          do
+          names <- map normalizeField `fmap` getColumnNames sth
+          rows <- fetchAllRows sth
+          return $ map (zip names) rows
 
 -- | Primitive execute
 hdbcPrimExecute :: (IConnection conn) => conn -- ^ Database connection.
@@ -201,6 +209,6 @@
 
 -- hdbcGetValue :: Data.Convertible.Base.Convertible SqlValue a
 --             => HDBCRow -> String -> IO (Maybe a)
-hdbcGetValue m f = case Map.lookup (map toLower f) m of
+hdbcGetValue m f = case Map.lookup (normalizeField f) m of
                      Nothing -> fail $ "No such field " ++ f
                      Just x  -> return $ HDBC.fromSql x
