packages feed

sqlite-simple 0.4.9.0 → 0.4.10.0

raw patch · 5 files changed

+44/−3 lines, 5 files

Files

Database/SQLite/Simple.hs view
@@ -67,6 +67,8 @@   , queryWith_   , queryNamed   , lastInsertRowId+  , changes+  , totalChanges     -- * Queries that stream results   , fold   , fold_@@ -419,7 +421,7 @@       case maybeNextRow of         Just row  -> do           val' <- action val row-          loop val'+          val' `seq` loop val'         Nothing   -> return val  -- | Extracts the next row from the prepared statement.@@ -472,6 +474,20 @@ lastInsertRowId :: Connection -> IO Int64 lastInsertRowId (Connection c) = BaseD.lastInsertRowId c +-- | <http://www.sqlite.org/c3ref/changes.html>+--+-- Return the number of rows that were changed, inserted, or deleted+-- by the most recent @INSERT@, @DELETE@, or @UPDATE@ statement.+changes :: Connection -> IO Int+changes (Connection c) = BaseD.changes c++-- | <http://www.sqlite.org/c3ref/total_changes.html>+--+-- Return the total number of row changes caused by @INSERT@, @DELETE@,+-- or @UPDATE@ statements since the 'Database' was opened.+totalChanges :: Connection -> IO Int+totalChanges (Connection c) = BaseD.totalChanges c+ -- | Run an IO action inside a SQL transaction started with @BEGIN -- TRANSACTION@.  If the action throws any kind of an exception, the -- transaction will be rolled back with @ROLLBACK TRANSACTION@.@@ -562,7 +578,8 @@ -- > -- > hello = do -- >   conn <- open "test.db"--- >   query conn "select 2 + 2"+-- >   [[x]] <- query_ conn "select 2 + 2"+-- >   print x -- -- A 'Query' value does not represent the actual query that will be -- executed, but is a template for constructing the final query.
changelog view
@@ -1,3 +1,6 @@+0.4.10.0+	* Expose sqlite3_changes/total_changes+ 0.4.9.0 	* Provide queryWith_ to allow more fine-grained access to 	  constructing queries.
sqlite-simple.cabal view
@@ -1,5 +1,5 @@ Name:                sqlite-simple-Version:             0.4.9.0+Version:             0.4.10.0 Synopsis:            Mid-Level SQLite client library Description:     Mid-level SQLite client library, based on postgresql-simple.
test/Main.hs view
@@ -30,6 +30,7 @@     , TestLabel "Simple"    . testSimpleUTCTimeParams     , TestLabel "Simple"    . testSimpleQueryCov     , TestLabel "Simple"    . testSimpleStrings+    , TestLabel "Simple"    . testSimpleChanges     , TestLabel "ParamConv" . testParamConvNull     , TestLabel "ParamConv" . testParamConvInt     , TestLabel "ParamConv" . testParamConvIntWidths
test/Simple.hs view
@@ -12,6 +12,7 @@   , testSimpleUTCTimeParams   , testSimpleQueryCov   , testSimpleStrings+  , testSimpleChanges   ) where  import qualified Data.ByteString as BS@@ -235,3 +236,22 @@   s @=? "strBsPLazy"   [Only s] <- query conn "SELECT ?" (Only ("strBsPLazy2" :: BS.ByteString)) :: IO [Only LBS.ByteString]   s @=? "strBsPLazy2"++testSimpleChanges :: TestEnv -> Test+testSimpleChanges TestEnv{..} = TestCase $ do+  execute_ conn "CREATE TABLE testchanges (id INTEGER PRIMARY KEY, t TEXT)"+  execute conn "INSERT INTO testchanges(t) VALUES (?)" (Only ("test string" :: String))+  numChanges <- changes conn+  assertEqual "changed/inserted rows" 1 numChanges+  execute conn "INSERT INTO testchanges(t) VALUES (?)" (Only ("test string 2" :: String))+  numChanges <- changes conn+  assertEqual "changed/inserted rows" 1 numChanges+  execute_ conn "UPDATE testchanges SET t = 'foo' WHERE id = 1"+  numChanges <- changes conn+  assertEqual "changed/inserted rows" 1 numChanges+  execute_ conn "UPDATE testchanges SET t = 'foo' WHERE id = 100"+  numChanges <- changes conn+  assertEqual "changed/inserted rows" 0 numChanges+  execute_ conn "UPDATE testchanges SET t = 'foo'"+  numChanges <- changes conn+  assertEqual "changed/inserted rows" 2 numChanges