packages feed

HDBC-sqlite3 2.1.0.2 → 2.2.0.0

raw patch · 5 files changed

+56/−6 lines, 5 filesdep ~HDBCdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: HDBC, base

API changes (from Hackage documentation)

Files

Database/HDBC/Sqlite3/Connection.hs view
@@ -81,6 +81,7 @@                             Impl.commit = fcommit obj children,                             Impl.rollback = frollback obj children,                             Impl.run = frun obj children,+                            Impl.runRaw = frunRaw obj children,                             Impl.prepare = newSth obj children True,                             Impl.clone = connectSqlite3 fp,                             Impl.hdbcDriverName = "sqlite3",@@ -115,6 +116,12 @@        res <- execute sth args        finish sth        return res++frunRaw :: Sqlite3 -> ChildList -> String -> IO ()+frunRaw o mchildren query =+    do sth <- newSth o mchildren False query+       executeRaw sth+       finish sth  fcommit o children = do frun o children "COMMIT" []                         begin_transaction o children
Database/HDBC/Sqlite3/ConnectionImpl.hs view
@@ -28,6 +28,7 @@                 commit :: IO (),                 rollback :: IO (),                 run :: String -> [Types.SqlValue] -> IO Integer,+                runRaw :: String -> IO (),                 prepare :: String -> IO Types.Statement,                 clone :: IO Connection,                 hdbcDriverName :: String,@@ -48,6 +49,7 @@   commit = commit   rollback = rollback   run = run+  runRaw = runRaw   prepare = prepare   clone = clone   hdbcDriverName = hdbcDriverName
Database/HDBC/Sqlite3/Statement.hsc view
@@ -73,6 +73,7 @@        modifyMVar_ (stomv sstate) (\_ -> (fprepare sstate >>= return . Prepared))        let retval =                 Statement {execute = fexecute sstate,+                           executeRaw = fexecuteRaw indbo str,                            executeMany = fexecutemany sstate,                            finish = public_ffinish sstate,                            fetchRow = ffetchrow sstate,@@ -206,6 +207,23 @@                  checkError ("execute (binding column " ++                               (show i) ++ ")") (dbo sstate) r +fexecuteRaw :: Sqlite3 -> String -> IO ()+fexecuteRaw dbo query =+    withSqlite3 dbo+      (\p -> B.useAsCStringLen (BUTF8.fromString (query ++ "\0"))+       (\(cs, cslen) -> do+          result <- sqlite3_exec p cs nullFunPtr nullPtr nullPtr+          case result of+            #{const SQLITE_OK} -> return ()+            s -> do+              checkError "exec" dbo #{const SQLITE_ERROR}+              throwSqlError $ SqlError+                 {seState = "",+                  seNativeError = fromIntegral s,+                  seErrorMsg = "In sqlite3_exec, internal error"}+       )+      )+ fgetcolnames csth =         do count <- sqlite3_column_count csth            mapM (getCol csth) [0..(count -1)]@@ -247,6 +265,14 @@  foreign import ccall unsafe "sqlite3.h sqlite3_step"   sqlite3_step :: (Ptr CStmt) -> IO CInt++foreign import ccall unsafe "sqlite3.h sqlite3_exec"+  sqlite3_exec :: (Ptr CSqlite3)+               -> CString+               -> FunPtr (Ptr () -> CInt -> Ptr CString -> Ptr CString)+               -> Ptr ()+               -> Ptr CString+               -> IO CInt  foreign import ccall unsafe "sqlite3.h sqlite3_reset"   sqlite3_reset :: (Ptr CStmt) -> IO CInt
HDBC-sqlite3.cabal view
@@ -1,5 +1,5 @@ Name: HDBC-sqlite3-Version: 2.1.0.2+Version: 2.2.0.0 License: LGPL Maintainer: John Goerzen <jgoerzen@complete.org> Author: John Goerzen@@ -21,14 +21,10 @@   default: False  Library-  if flag(splitBase)-    Build-Depends: base>=3 && < 5, bytestring-  else-    Build-Depends: base<3 && < 5+  Build-Depends: base>=3 && < 5, bytestring, mtl, HDBC>=2.2.0, utf8-string    if impl(ghc >= 6.9)     Build-Depends: base >= 4 && < 5-  Build-Depends: mtl, HDBC>=2.1.0, utf8-string    C-Sources: hdbc-sqlite3-helper.c   include-dirs: .
testsrc/TestSbasics.hs view
@@ -17,6 +17,23 @@        finish sth                           ) +runRawTest = dbTestCase (\dbh ->+    do runRaw dbh "CREATE TABLE valid1 (a int); CREATE TABLE valid2 (a int)"+       tables <- getTables dbh+       assertBool "valid1 table not created!" ("valid1" `elem` tables)+       assertBool "valid2 table not created!" ("valid2" `elem` tables)+                        )+++runRawErrorTest = dbTestCase (\dbh ->+    do err <- (runRaw dbh "CREATE TABLE valid1 (a int); INVALID" >> return "No error") `catchSql`+              (return . seErrorMsg)+       assertEqual "exception text" "exec: near \"INVALID\": syntax error" err+       rollback dbh+       tables <- getTables dbh+       assertBool "valid1 table created!" (not $ "valid1" `elem` tables)+                        )+ basicQueries = dbTestCase (\dbh ->     do sth <- prepare dbh "SELECT 1 + 1"        sExecute sth []@@ -138,6 +155,8 @@         [          TestLabel "openClosedb" openClosedb,          TestLabel "multiFinish" multiFinish,+         TestLabel "runRawTest" runRawTest,+         TestLabel "runRawErrorTest" runRawErrorTest,          TestLabel "basicQueries" basicQueries,          TestLabel "createTable" createTable,          TestLabel "runReplace" runReplace,