packages feed

selda-sqlite 0.1.1.0 → 0.1.2.0

raw patch · 2 files changed

+21/−13 lines, 2 filesdep ~seldaPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: selda

API changes (from Hackage documentation)

Files

selda-sqlite.cabal view
@@ -1,5 +1,5 @@ name:                selda-sqlite-version:             0.1.1.0+version:             0.1.2.0 synopsis:            SQLite backend for the Selda database EDSL. description:         SQLite backend for the Selda database EDSL. homepage:            https://github.com/valderman/selda@@ -22,10 +22,10 @@     GADTs     CPP   build-depends:-      base          >=4.8   && <5-    , exceptions    >=0.8   && <0.9-    , selda         >=0.1.1 && <0.2-    , text          >=1.0   && <1.3+      base          >=4.8     && <5+    , exceptions    >=0.8     && <0.9+    , selda         >=0.1.3.2 && <0.2+    , text          >=1.0     && <1.3   if !flag(haste)     build-depends:       direct-sqlite >=2.2 && <2.4
src/Database/Selda/SQLite.hs view
@@ -18,8 +18,12 @@ #else withSQLite file m = do   lock <- liftIO $ newMVar ()-  db <- liftIO $ open (pack file)-  runSeldaT m (sqliteBackend lock db) `finally` liftIO (close db)+  edb <- try $ liftIO $ open (pack file)+  case edb of+    Left e@(SQLError{}) -> do+      throwM (DbError (show e))+    Right db -> do+      runSeldaT m (sqliteBackend lock db) `finally` liftIO (close db)  sqliteBackend :: MVar () -> Database -> SeldaBackend sqliteBackend lock db = SeldaBackend@@ -31,11 +35,15 @@  sqliteQueryRunner :: MVar () -> Database -> QueryRunner (Int, (Int, [[SqlValue]])) sqliteQueryRunner lock db qry params = do-    stm <- prepare db qry-    takeMVar lock-    go stm `finally` do-      putMVar lock ()-      finalize stm+    eres <- try $ do+      stm <- prepare db qry+      takeMVar lock+      go stm `finally` do+        putMVar lock ()+        finalize stm+    case eres of+      Left e@(SQLError{}) -> throwM (SqlError (show e))+      Right res           -> return res   where     go stm = do       bind stm [toSqlData p | Param p <- params]@@ -68,6 +76,6 @@ fromSqlData (SQLInteger i) = SqlInt $ fromIntegral i fromSqlData (SQLFloat f)   = SqlFloat f fromSqlData (SQLText s)    = SqlString s-fromSqlData (SQLBlob _)    = error "Selda doesn't support blobs"+fromSqlData (SQLBlob _)    = error "BUG: SQLite returned BLOB" fromSqlData SQLNull        = SqlNull #endif