selda-sqlite 0.1.5.1 → 0.1.6.0
raw patch · 2 files changed
+20/−21 lines, 2 filesdep ~exceptionsdep ~seldaPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: exceptions, selda
API changes (from Hackage documentation)
- Database.Selda.SQLite: sqliteOpen :: (MonadIO m, MonadCatch m) => FilePath -> m SeldaConnection
+ Database.Selda.SQLite: sqliteOpen :: (MonadIO m, MonadMask m) => FilePath -> m SeldaConnection
Files
- selda-sqlite.cabal +7/−7
- src/Database/Selda/SQLite.hs +13/−14
selda-sqlite.cabal view
@@ -1,5 +1,5 @@ name: selda-sqlite-version: 0.1.5.1+version: 0.1.6.0 synopsis: SQLite backend for the Selda database EDSL. description: SQLite backend for the Selda database EDSL. homepage: https://github.com/valderman/selda@@ -22,14 +22,14 @@ GADTs CPP build-depends:- base >=4.8 && <5- , exceptions >=0.8 && <0.9- , selda >=0.1.8.0 && <0.2- , text >=1.0 && <1.3+ base >=4.8 && <5+ , exceptions >=0.8 && <0.9+ , selda >=0.1.10.0 && <0.2+ , text >=1.0 && <1.3 if !flag(haste) build-depends:- direct-sqlite >=2.2 && <2.4- , directory >=1.2.2 && <1.4+ direct-sqlite >=2.2 && <2.4+ , directory >=1.2.2 && <1.4 hs-source-dirs: src default-language:
src/Database/Selda/SQLite.hs view
@@ -14,20 +14,21 @@ -- | Open a new connection to an SQLite database. -- The connection is reusable across calls to `runSeldaT`, and must be -- explicitly closed using 'seldaClose' when no longer needed.-sqliteOpen :: (MonadIO m, MonadCatch m) => FilePath -> m SeldaConnection+sqliteOpen :: (MonadIO m, MonadMask m) => FilePath -> m SeldaConnection sqliteOpen file = do #ifdef __HASTE__ error "sqliteOpen called in JS context" #else- edb <- try $ liftIO $ open (pack file)- case edb of- Left e@(SQLError{}) -> do- throwM (DbError (show e))- Right db -> do- absFile <- liftIO $ pack <$> makeAbsolute file- let backend = sqliteBackend db- liftIO $ runStmt backend "PRAGMA foreign_keys = ON;" []- newConnection backend absFile+ mask $ \restore -> do+ edb <- try $ liftIO $ open (pack file)+ case edb of+ Left e@(SQLError{}) -> do+ throwM (DbError (show e))+ Right db -> flip onException (liftIO (close db)) . restore $ do+ absFile <- liftIO $ pack <$> makeAbsolute file+ let backend = sqliteBackend db+ liftIO $ runStmt backend "PRAGMA foreign_keys = ON;" []+ newConnection backend absFile #endif -- | Perform the given computation over an SQLite database.@@ -36,9 +37,7 @@ #ifdef __HASTE__ withSQLite _ _ = return $ error "withSQLite called in JS context" #else-withSQLite file m = do- conn <- sqliteOpen file- runSeldaT m conn `finally` seldaClose conn+withSQLite file m = bracket (sqliteOpen file) seldaClose (runSeldaT m) sqliteBackend :: Database -> SeldaBackend sqliteBackend db = SeldaBackend@@ -46,7 +45,7 @@ , runStmtWithPK = \q ps -> fst <$> sqliteQueryRunner db q ps , prepareStmt = \_ _ -> sqlitePrepare db , runPrepared = sqliteRunPrepared db- , ppConfig = defPPConfig+ , ppConfig = defPPConfig {ppMaxInsertParams = Just 999} , backendId = SQLite , closeConnection = \conn -> do stmts <- allStmts conn