hdbi 1.0.0 → 1.1.0
raw patch · 3 files changed
+11/−14 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Database.HDBI.Types: affectedRows :: Statement stmt => stmt -> IO Integer
- Database.HDBI.Types: class Typeable stmt => Statement stmt where executeRaw stmt = execute stmt [] executeMany stmt vals = mapM_ (execute stmt) vals fetchAllRows stmt = do { e <- f mempty; return $ (appEndo e) [] } where f acc = do { res <- fetchRow stmt; case res of { Just r -> f (acc `mappend` (Endo (r :))) Nothing -> return acc } } getColumnsCount stmt = fmap length $ getColumnNames stmt
+ Database.HDBI.Types: class Typeable stmt => Statement stmt where executeRaw stmt = execute stmt [] executeMany stmt vals = forM_ vals $ \ val -> do { execute stmt val; reset stmt } fetchAllRows stmt = do { e <- f mempty; return $ (appEndo e) [] } where f acc = do { res <- fetchRow stmt; case res of { Just r -> f (acc `mappend` (Endo (r :))) Nothing -> return acc } } getColumnsCount stmt = fmap length $ getColumnNames stmt
Files
- Database/HDBI/Types.hs +10/−12
- hdbi.cabal +1/−1
- testsrc/dummydriver.hs +0/−1
Database/HDBI/Types.hs view
@@ -40,17 +40,19 @@ , withStatement ) where + import Prelude hiding (catch)-import qualified Data.Text.Lazy as TL-import Database.HDBI.SqlValue (SqlValue) import Control.Applicative ((<$>))-import Control.Exception (Exception(..), SomeException, try, catch, throwIO, bracket) import Control.DeepSeq (NFData(..))-import Data.Typeable-import Data.String (IsString(..))+import Control.Exception (Exception(..), SomeException, try, catch, throwIO, bracket)+import Control.Monad (forM_) import Data.Data (Data(..)) import Data.Monoid (Monoid(..), Endo(..))+import Data.String (IsString(..))+import Data.Typeable+import Database.HDBI.SqlValue (SqlValue)+import qualified Data.Text.Lazy as TL -- | Error throwing by driver when database operation fails data SqlError =@@ -211,16 +213,13 @@ -- | Execute one query many times with a list of paramters. Has default -- implementation through 'execute'. executeMany :: stmt -> [[SqlValue]] -> IO ()- executeMany stmt vals = mapM_ (execute stmt) vals+ executeMany stmt vals = forM_ vals $ \val -> do+ execute stmt val+ reset stmt -- | Return the current statement's status. statementStatus :: stmt -> IO StatementStatus - -- | Return the count of rows affected by INSERT, UPDATE or DELETE- -- query. After executing SELECT query it will return 0 every time.- -- It is also undefined result after executing 'executeMany'- affectedRows :: stmt -> IO Integer- -- | Finish statement and remove database-specific pointer. No any actions may -- be proceeded after closing the statement, excpet 'statementStatus' which -- will return 'StatementFinished' and 'reset'.@@ -272,7 +271,6 @@ executeRaw (StmtWrapper stmt) = executeRaw stmt executeMany (StmtWrapper stmt) = executeMany stmt statementStatus (StmtWrapper stmt) = statementStatus stmt- affectedRows (StmtWrapper stmt) = affectedRows stmt finish (StmtWrapper stmt) = finish stmt reset (StmtWrapper stmt) = reset stmt fetchRow (StmtWrapper stmt) = fetchRow stmt
hdbi.cabal view
@@ -1,5 +1,5 @@ Name: hdbi-Version: 1.0.0+Version: 1.1.0 License: BSD3 Maintainer: Aleksey Uymanov <s9gf4ult@gmail.com> Author: John Goerzen
testsrc/dummydriver.hs view
@@ -126,7 +126,6 @@ statementStatus = readMVar . dsStatus - affectedRows = const $ return 0 finish stmt = modifyMVar_ (dsStatus stmt) $ const $ return StatementFinished reset stmt = modifyMVar_ (dsStatus stmt) $ const $ return StatementNew fetchRow stmt = modifyMVar (dsSelecting stmt) $ \slct -> case slct of