X-Git-Url: http://gitweb.michael.orlitzky.com/?p=list-remote-forwards.git;a=blobdiff_plain;f=src%2FReport.hs;h=dd3ce4e9ae5d698c7d9985c2e32f7e937a10f2dd;hp=5b3853350efc3a07c581ad20b354741c3d127cc5;hb=ae4cdbc0662d67d3d325c8ab567e0d45a84413b3;hpb=f75845314598408bce3a1b972f2ba274d93d0e8d diff --git a/src/Report.hs b/src/Report.hs index 5b38533..dd3ce4e 100644 --- a/src/Report.hs +++ b/src/Report.hs @@ -1,5 +1,3 @@ -{-# LANGUAGE PatternGuards #-} - module Report ( report, report_tests ) @@ -13,6 +11,7 @@ import qualified Data.Set as Set ( map ) import Data.String.Utils ( join ) import Database.HDBC ( IConnection, + Statement, execute, prepare, sFetchAllRows') @@ -35,6 +34,17 @@ import MxList ( MxList(..) ) -- WARNING: Also defined in the "Forward" module. type Domain = String + +-- | We really want executeRaw here, but there's a bug: it will tell +-- us we can't fetch rows from the statement since it hasn't been +-- executed yet! +-- +my_executeRaw :: Statement -> IO [[Maybe String]] +my_executeRaw stmt = do + _ <- execute stmt [] + sFetchAllRows' stmt + + -- | Given a connection @conn@ and a @query@, return a list of domains -- found by executing @query@ on @conn. The @query@ is assumed to -- return only one column, containing domains. @@ -45,14 +55,7 @@ get_domain_list :: IConnection a -> IO [Domain] -- ^ The list of domains returned from @query@ get_domain_list conn query = do stmt <- prepare conn query - - -- We really want executeRaw here, but there's a bug: it will tell - -- us we can't fetch rows from the statement since it hasn't been - -- executed yet! - _ <- execute stmt [] - - -- rows :: [[Maybe String]] - rows <- sFetchAllRows' stmt + rows <- my_executeRaw stmt -- rows' :: [Maybe String] let rows' = map (listToMaybe . catMaybes) rows @@ -77,14 +80,7 @@ get_forward_list :: IConnection a -> IO [Forward] -- ^ A list of forwards returned from @query@ get_forward_list conn query = do stmt <- prepare conn query - - -- We really want executeRaw here, but there's a bug: it will tell - -- us we can't fetch rows from the statement since it hasn't been - -- executed yet! - _ <- execute stmt [] - - -- rows :: [[Maybe String]] - rows <- sFetchAllRows' stmt + rows <- my_executeRaw stmt -- forwards :: [Forward] let forwards = concatMap (strings_to_forwards . catMaybes) rows