yesod-persistent 1.4.0.4 → 1.4.0.5
raw patch · 2 files changed
+24/−5 lines, 2 filesdep ~persistentdep ~persistent-template
Dependency ranges changed: persistent, persistent-template
Files
- Yesod/Persist/Core.hs +21/−2
- yesod-persistent.cabal +3/−3
Yesod/Persist/Core.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-}@@ -20,7 +21,7 @@ ) where import Database.Persist-import Control.Monad.Trans.Reader (ReaderT, runReaderT)+import Control.Monad.Trans.Reader (ReaderT, runReaderT, withReaderT) import Yesod.Core import Data.Conduit@@ -80,12 +81,18 @@ -- | Helper for implementing 'getDBRunner'. -- -- Since 1.2.0+#if MIN_VERSION_persistent(2,5,0)+defaultGetDBRunner :: (SQL.IsSqlBackend backend, YesodPersistBackend site ~ backend)+ => (site -> Pool backend)+ -> HandlerT site IO (DBRunner site, HandlerT site IO ())+#else defaultGetDBRunner :: YesodPersistBackend site ~ SQL.SqlBackend => (site -> Pool SQL.SqlBackend) -> HandlerT site IO (DBRunner site, HandlerT site IO ())+#endif defaultGetDBRunner getPool = do pool <- fmap getPool getYesod- let withPrep conn f = f conn (SQL.connPrepare conn)+ let withPrep conn f = f (persistBackend conn) (SQL.connPrepare $ persistBackend conn) (relKey, (conn, local)) <- allocate (do (conn, local) <- takeResource pool@@ -124,9 +131,15 @@ respondSourceDB ctype = respondSource ctype . runDBSource -- | Get the given entity by ID, or return a 404 not found if it doesn't exist.+#if MIN_VERSION_persistent(2,5,0)+get404 :: (MonadIO m, PersistStore backend, PersistRecordBackend val backend)+ => Key val+ -> ReaderT backend m val+#else get404 :: (MonadIO m, PersistStore (PersistEntityBackend val), PersistEntity val) => Key val -> ReaderT (PersistEntityBackend val) m val+#endif get404 key = do mres <- get key case mres of@@ -135,9 +148,15 @@ -- | Get the given entity by unique key, or return a 404 not found if it doesn't -- exist.+#if MIN_VERSION_persistent(2,5,0)+getBy404 :: (PersistUnique backend, PersistRecordBackend val backend, MonadIO m)+ => Unique val+ -> ReaderT backend m (Entity val)+#else getBy404 :: (PersistUnique (PersistEntityBackend val), PersistEntity val, MonadIO m) => Unique val -> ReaderT (PersistEntityBackend val) m (Entity val)+#endif getBy404 key = do mres <- getBy key case mres of
yesod-persistent.cabal view
@@ -1,5 +1,5 @@ name: yesod-persistent-version: 1.4.0.4+version: 1.4.0.5 license: MIT license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>@@ -16,8 +16,8 @@ library build-depends: base >= 4 && < 5 , yesod-core >= 1.4.0 && < 1.5- , persistent >= 2.1 && < 2.3- , persistent-template >= 2.1 && < 2.2+ , persistent >= 2.1 && < 2.6+ , persistent-template >= 2.1 && < 2.6 , transformers >= 0.2.2 , blaze-builder , conduit