From 7b35665d73c0fe2376a2963e6623c77e5e555dff Mon Sep 17 00:00:00 2001 From: Eric Easley Date: Sun, 7 Feb 2016 19:11:41 -0800 Subject: [PATCH 01/12] Adjust yesod-persistent for split DB --- yesod-persistent/Yesod/Persist/Core.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/yesod-persistent/Yesod/Persist/Core.hs b/yesod-persistent/Yesod/Persist/Core.hs index c5667073..d54485d5 100644 --- a/yesod-persistent/Yesod/Persist/Core.hs +++ b/yesod-persistent/Yesod/Persist/Core.hs @@ -20,7 +20,7 @@ module Yesod.Persist.Core ) 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 @@ -124,9 +124,9 @@ respondSourceDB :: YesodPersistRunner site respondSourceDB ctype = respondSource ctype . runDBSource -- | Get the given entity by ID, or return a 404 not found if it doesn't exist. -get404 :: (MonadIO m, PersistStore (PersistEntityBackend val), PersistEntity val) +get404 :: (MonadIO m, PersistStore backend, BaseBackend backend ~ PersistEntityBackend val, PersistEntity val) => Key val - -> ReaderT (PersistEntityBackend val) m val + -> ReaderT backend m val get404 key = do mres <- get key case mres of @@ -135,9 +135,9 @@ get404 key = do -- | Get the given entity by unique key, or return a 404 not found if it doesn't -- exist. -getBy404 :: (PersistUnique (PersistEntityBackend val), PersistEntity val, MonadIO m) +getBy404 :: (PersistUnique backend, BaseBackend backend ~ PersistEntityBackend val, PersistEntity val, MonadIO m) => Unique val - -> ReaderT (PersistEntityBackend val) m (Entity val) + -> ReaderT backend m (Entity val) getBy404 key = do mres <- getBy key case mres of From 1dea0ef5b10a0d871477fd0632225e468102267a Mon Sep 17 00:00:00 2001 From: Eric Easley Date: Sun, 7 Feb 2016 19:15:57 -0800 Subject: [PATCH 02/12] Adjust yesod-form for split DB --- yesod-form/Yesod/Form/Fields.hs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/yesod-form/Yesod/Form/Fields.hs b/yesod-form/Yesod/Form/Fields.hs index 5ccbe208..41dbc83c 100644 --- a/yesod-form/Yesod/Form/Fields.hs +++ b/yesod-form/Yesod/Form/Fields.hs @@ -74,7 +74,7 @@ import Data.Text.Encoding (encodeUtf8, decodeUtf8With) import Data.Text.Encoding.Error (lenientDecode) import Network.URI (parseURI) import Database.Persist.Sql (PersistField, PersistFieldSql (..)) -import Database.Persist (Entity (..), SqlType (SqlString)) +import Database.Persist (Entity (..), SqlType (SqlString), BaseBackend, PersistQueryRead) import Text.HTML.SanitizeXSS (sanitizeBalance) import Control.Monad (when, unless) import Data.Either (partitionEithers) @@ -645,11 +645,13 @@ optionsEnum = optionsPairs $ map (\x -> (pack $ show x, x)) [minBound..maxBound] -- > <$> areq (selectField countries) "Which country do you live in?" Nothing -- > where -- > countries = optionsPersist [] [Asc CountryName] countryName -optionsPersist :: ( YesodPersist site, PersistEntity a - , PersistQuery (PersistEntityBackend a) +optionsPersist :: ( YesodPersist site + , PersistEntity a + , PersistQueryRead backend , PathPiece (Key a) , RenderMessage site msg - , YesodPersistBackend site ~ PersistEntityBackend a + , YesodPersistBackend site ~ backend + , BaseBackend backend ~ PersistEntityBackend a ) => [Filter a] -> [SelectOpt a] @@ -671,10 +673,11 @@ optionsPersist filts ords toDisplay = fmap mkOptionList $ do optionsPersistKey :: (YesodPersist site , PersistEntity a - , PersistQuery (PersistEntityBackend a) + , PersistQueryRead backend , PathPiece (Key a) , RenderMessage site msg - , YesodPersistBackend site ~ PersistEntityBackend a + , backend ~ YesodPersistBackend site + , BaseBackend backend ~ PersistEntityBackend a ) => [Filter a] -> [SelectOpt a] From 4bc4fc3b368186455939d8efe4ae13a223cbcfa0 Mon Sep 17 00:00:00 2001 From: Eric Easley Date: Sun, 7 Feb 2016 19:17:50 -0800 Subject: [PATCH 03/12] Adjust yesod-auth for split DB --- yesod-auth/Yesod/Auth.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yesod-auth/Yesod/Auth.hs b/yesod-auth/Yesod/Auth.hs index db9e7331..70ecde59 100644 --- a/yesod-auth/Yesod/Auth.hs +++ b/yesod-auth/Yesod/Auth.hs @@ -500,10 +500,10 @@ class (YesodAuth master, YesodPersist master) => YesodAuthPersist master where getAuthEntity :: AuthId master -> HandlerT master IO (Maybe (AuthEntity master)) default getAuthEntity - :: ( YesodPersistBackend master - ~ PersistEntityBackend (AuthEntity master) + :: ( YesodPersistBackend master ~ backend + , BaseBackend backend ~ PersistEntityBackend (AuthEntity master) , Key (AuthEntity master) ~ AuthId master - , PersistStore (YesodPersistBackend master) + , PersistStore backend , PersistEntity (AuthEntity master) ) => AuthId master -> HandlerT master IO (Maybe (AuthEntity master)) From dbffca825c3fef2b74e6db372bed446f4c453cb2 Mon Sep 17 00:00:00 2001 From: Eric Easley Date: Thu, 11 Feb 2016 13:14:27 -0800 Subject: [PATCH 04/12] Update stack.yaml to point at modified persistent --- stack.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stack.yaml b/stack.yaml index 3c1e5bb0..5572e25e 100644 --- a/stack.yaml +++ b/stack.yaml @@ -13,7 +13,13 @@ packages: - ./yesod - ./yesod-eventsource - ./yesod-websockets + - location: + git: git@github.com:pseudonom/persistent.git + commit: 97050a636131c399cd6dca7ec83a02a27691cdae + subdirs: + - persistent # Needed for LTS 2 extra-deps: - wai-app-static-3.1.4.1 +- http-api-data-0.2.2 From 8ce9a6b088f32c274f225c08e44bf7513e108d3a Mon Sep 17 00:00:00 2001 From: Eric Easley Date: Wed, 30 Mar 2016 16:20:44 -0700 Subject: [PATCH 05/12] Update to finalized (?) persistent --- stack.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.yaml b/stack.yaml index 5572e25e..78ec4e72 100644 --- a/stack.yaml +++ b/stack.yaml @@ -15,7 +15,7 @@ packages: - ./yesod-websockets - location: git: git@github.com:pseudonom/persistent.git - commit: 97050a636131c399cd6dca7ec83a02a27691cdae + commit: 0edba747e49c816e94c235bced16978cb729b175 subdirs: - persistent From 3b387b714988024f90c12b53a037735682ad253f Mon Sep 17 00:00:00 2001 From: Eric Easley Date: Thu, 31 Mar 2016 01:06:39 -0700 Subject: [PATCH 07/12] Used HTTPS instead of ssh --- stack.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.yaml b/stack.yaml index 78ec4e72..ec929514 100644 --- a/stack.yaml +++ b/stack.yaml @@ -14,7 +14,7 @@ packages: - ./yesod-eventsource - ./yesod-websockets - location: - git: git@github.com:pseudonom/persistent.git + git: https://github.com/pseudonom/persistent.git commit: 0edba747e49c816e94c235bced16978cb729b175 subdirs: - persistent From 329735e8156cece431541bd06567bb4442852fe0 Mon Sep 17 00:00:00 2001 From: Eric Easley Date: Thu, 31 Mar 2016 13:38:32 -0700 Subject: [PATCH 08/12] Fix `http-api-data` version for lts 2 --- stack.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.yaml b/stack.yaml index 2301a9f1..5224ddd8 100644 --- a/stack.yaml +++ b/stack.yaml @@ -22,4 +22,4 @@ packages: # Needed for LTS 2 extra-deps: - wai-app-static-3.1.4.1 -- http-api-data-0.2.2 +- http-api-data-0.2 From 8a9a78bd4cc99d12c73e291971e5990cdae8921d Mon Sep 17 00:00:00 2001 From: Eric Easley Date: Sun, 10 Apr 2016 13:04:48 -0700 Subject: [PATCH 09/12] Generalize `defaultGetDBRunner` --- stack.yaml | 2 +- yesod-persistent/Yesod/Persist/Core.hs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/stack.yaml b/stack.yaml index 5224ddd8..c99d451b 100644 --- a/stack.yaml +++ b/stack.yaml @@ -15,7 +15,7 @@ packages: - ./yesod-websockets - location: git: https://github.com/pseudonom/persistent.git - commit: 0edba747e49c816e94c235bced16978cb729b175 + commit: 1b7b70ed5d36adaffaf4cf9927fefcf16fec8969 subdirs: - persistent diff --git a/yesod-persistent/Yesod/Persist/Core.hs b/yesod-persistent/Yesod/Persist/Core.hs index d54485d5..abc77b53 100644 --- a/yesod-persistent/Yesod/Persist/Core.hs +++ b/yesod-persistent/Yesod/Persist/Core.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} @@ -80,12 +81,12 @@ newtype DBRunner site = DBRunner -- | Helper for implementing 'getDBRunner'. -- -- Since 1.2.0 -defaultGetDBRunner :: YesodPersistBackend site ~ SQL.SqlBackend - => (site -> Pool SQL.SqlBackend) +defaultGetDBRunner :: (SQL.IsSqlBackend backend, YesodPersistBackend site ~ backend) + => (site -> Pool backend) -> HandlerT site IO (DBRunner site, HandlerT site IO ()) 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 From bf3a9c9dd4aad39e9a8c0e26e187d360a47fc80a Mon Sep 17 00:00:00 2001 From: Eric Easley Date: Thu, 14 Apr 2016 15:14:56 -0700 Subject: [PATCH 10/12] Switch to released `persistent-2.5` --- stack.yaml | 6 +----- yesod-auth/yesod-auth.cabal | 2 +- yesod-persistent/yesod-persistent.cabal | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/stack.yaml b/stack.yaml index d57283c3..fb3b7b71 100644 --- a/stack.yaml +++ b/stack.yaml @@ -13,14 +13,10 @@ packages: - ./yesod - ./yesod-eventsource - ./yesod-websockets - - location: - git: https://github.com/yesodweb/persistent.git - commit: 4cb12ad1e240d190647ea75f1bc784fa6b5b7cc2 - subdirs: - - persistent # Needed for LTS 2 extra-deps: - wai-app-static-3.1.4.1 - http-api-data-0.2 - yaml-0.8.17 +- persistent-2.5 diff --git a/yesod-auth/yesod-auth.cabal b/yesod-auth/yesod-auth.cabal index a388396f..e817ba0e 100644 --- a/yesod-auth/yesod-auth.cabal +++ b/yesod-auth/yesod-auth.cabal @@ -37,7 +37,7 @@ library , unordered-containers , yesod-form >= 1.4 && < 1.5 , transformers >= 0.2.2 - , persistent >= 2.1 && < 2.3 + , persistent >= 2.5 && < 2.6 , persistent-template >= 2.1 && < 2.2 , http-client , http-conduit >= 2.1 diff --git a/yesod-persistent/yesod-persistent.cabal b/yesod-persistent/yesod-persistent.cabal index a12ca073..3054a1d6 100644 --- a/yesod-persistent/yesod-persistent.cabal +++ b/yesod-persistent/yesod-persistent.cabal @@ -16,7 +16,7 @@ extra-source-files: README.md ChangeLog.md library build-depends: base >= 4 && < 5 , yesod-core >= 1.4.0 && < 1.5 - , persistent >= 2.1 && < 2.3 + , persistent >= 2.5 && < 2.6 , persistent-template >= 2.1 && < 2.2 , transformers >= 0.2.2 , blaze-builder From 8e71f766b5c8d3305eb937efa513fdb31f40306f Mon Sep 17 00:00:00 2001 From: Eric Easley Date: Fri, 15 Apr 2016 21:25:40 -0700 Subject: [PATCH 11/12] Use `PersistRecordBackend` constraint synonym --- yesod-auth/Yesod/Auth.hs | 3 +-- yesod-form/Yesod/Form/Fields.hs | 9 ++++----- yesod-persistent/Yesod/Persist/Core.hs | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/yesod-auth/Yesod/Auth.hs b/yesod-auth/Yesod/Auth.hs index 8d251af0..7b72dbd8 100644 --- a/yesod-auth/Yesod/Auth.hs +++ b/yesod-auth/Yesod/Auth.hs @@ -501,10 +501,9 @@ class (YesodAuth master, YesodPersist master) => YesodAuthPersist master where default getAuthEntity :: ( YesodPersistBackend master ~ backend - , BaseBackend backend ~ PersistEntityBackend (AuthEntity master) + , PersistRecordBackend (AuthEntity master) backend , Key (AuthEntity master) ~ AuthId master , PersistStore backend - , PersistEntity (AuthEntity master) ) => AuthId master -> HandlerT master IO (Maybe (AuthEntity master)) getAuthEntity = runDB . get diff --git a/yesod-form/Yesod/Form/Fields.hs b/yesod-form/Yesod/Form/Fields.hs index b12e0f57..f9cee889 100644 --- a/yesod-form/Yesod/Form/Fields.hs +++ b/yesod-form/Yesod/Form/Fields.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE OverloadedStrings #-} @@ -74,7 +75,7 @@ import Data.Text.Encoding (encodeUtf8, decodeUtf8With) import Data.Text.Encoding.Error (lenientDecode) import Network.URI (parseURI) import Database.Persist.Sql (PersistField, PersistFieldSql (..)) -import Database.Persist (Entity (..), SqlType (SqlString), BaseBackend, PersistQueryRead) +import Database.Persist (Entity (..), SqlType (SqlString), PersistRecordBackend, PersistQueryRead) import Text.HTML.SanitizeXSS (sanitizeBalance) import Control.Monad (when, unless) import Data.Either (partitionEithers) @@ -646,12 +647,11 @@ optionsEnum = optionsPairs $ map (\x -> (pack $ show x, x)) [minBound..maxBound] -- > where -- > countries = optionsPersist [] [Asc CountryName] countryName optionsPersist :: ( YesodPersist site - , PersistEntity a , PersistQueryRead backend , PathPiece (Key a) , RenderMessage site msg , YesodPersistBackend site ~ backend - , BaseBackend backend ~ PersistEntityBackend a + , PersistRecordBackend a backend ) => [Filter a] -> [SelectOpt a] @@ -672,12 +672,11 @@ optionsPersist filts ords toDisplay = fmap mkOptionList $ do -- Since 1.3.2 optionsPersistKey :: (YesodPersist site - , PersistEntity a , PersistQueryRead backend , PathPiece (Key a) , RenderMessage site msg , backend ~ YesodPersistBackend site - , BaseBackend backend ~ PersistEntityBackend a + , PersistRecordBackend a backend ) => [Filter a] -> [SelectOpt a] diff --git a/yesod-persistent/Yesod/Persist/Core.hs b/yesod-persistent/Yesod/Persist/Core.hs index abc77b53..6cde856d 100644 --- a/yesod-persistent/Yesod/Persist/Core.hs +++ b/yesod-persistent/Yesod/Persist/Core.hs @@ -125,7 +125,7 @@ respondSourceDB :: YesodPersistRunner site respondSourceDB ctype = respondSource ctype . runDBSource -- | Get the given entity by ID, or return a 404 not found if it doesn't exist. -get404 :: (MonadIO m, PersistStore backend, BaseBackend backend ~ PersistEntityBackend val, PersistEntity val) +get404 :: (MonadIO m, PersistStore backend, PersistRecordBackend val backend) => Key val -> ReaderT backend m val get404 key = do @@ -136,7 +136,7 @@ get404 key = do -- | Get the given entity by unique key, or return a 404 not found if it doesn't -- exist. -getBy404 :: (PersistUnique backend, BaseBackend backend ~ PersistEntityBackend val, PersistEntity val, MonadIO m) +getBy404 :: (PersistUnique backend, PersistRecordBackend val backend, MonadIO m) => Unique val -> ReaderT backend m (Entity val) getBy404 key = do From d99de615547d0dd8bbc6f766b1749024403379a4 Mon Sep 17 00:00:00 2001 From: Eric Easley Date: Mon, 18 Apr 2016 10:03:39 -0700 Subject: [PATCH 12/12] Use CPP to maintain backward compat --- stack.yaml | 1 + yesod-auth/Yesod/Auth.hs | 11 +++++++++ yesod-auth/yesod-auth.cabal | 2 +- yesod-form/Yesod/Form/Fields.hs | 32 +++++++++++++++++++++++++ yesod-persistent/Yesod/Persist/Core.hs | 18 ++++++++++++++ yesod-persistent/yesod-persistent.cabal | 2 +- 6 files changed, 64 insertions(+), 2 deletions(-) diff --git a/stack.yaml b/stack.yaml index fb3b7b71..29b90e10 100644 --- a/stack.yaml +++ b/stack.yaml @@ -19,4 +19,5 @@ extra-deps: - wai-app-static-3.1.4.1 - http-api-data-0.2 - yaml-0.8.17 +- nonce-1.0.2 - persistent-2.5 diff --git a/yesod-auth/Yesod/Auth.hs b/yesod-auth/Yesod/Auth.hs index 7b72dbd8..9fe96010 100644 --- a/yesod-auth/Yesod/Auth.hs +++ b/yesod-auth/Yesod/Auth.hs @@ -499,6 +499,7 @@ class (YesodAuth master, YesodPersist master) => YesodAuthPersist master where getAuthEntity :: AuthId master -> HandlerT master IO (Maybe (AuthEntity master)) +#if MIN_VERSION_persistent(2,5,0) default getAuthEntity :: ( YesodPersistBackend master ~ backend , PersistRecordBackend (AuthEntity master) backend @@ -506,6 +507,16 @@ class (YesodAuth master, YesodPersist master) => YesodAuthPersist master where , PersistStore backend ) => AuthId master -> HandlerT master IO (Maybe (AuthEntity master)) +#else + default getAuthEntity + :: ( YesodPersistBackend master + ~ PersistEntityBackend (AuthEntity master) + , Key (AuthEntity master) ~ AuthId master + , PersistStore (YesodPersistBackend master) + , PersistEntity (AuthEntity master) + ) + => AuthId master -> HandlerT master IO (Maybe (AuthEntity master)) +#endif getAuthEntity = runDB . get diff --git a/yesod-auth/yesod-auth.cabal b/yesod-auth/yesod-auth.cabal index e817ba0e..1c0cb4f5 100644 --- a/yesod-auth/yesod-auth.cabal +++ b/yesod-auth/yesod-auth.cabal @@ -37,7 +37,7 @@ library , unordered-containers , yesod-form >= 1.4 && < 1.5 , transformers >= 0.2.2 - , persistent >= 2.5 && < 2.6 + , persistent >= 2.1 && < 2.6 , persistent-template >= 2.1 && < 2.2 , http-client , http-conduit >= 2.1 diff --git a/yesod-form/Yesod/Form/Fields.hs b/yesod-form/Yesod/Form/Fields.hs index f9cee889..e080062a 100644 --- a/yesod-form/Yesod/Form/Fields.hs +++ b/yesod-form/Yesod/Form/Fields.hs @@ -75,7 +75,11 @@ import Data.Text.Encoding (encodeUtf8, decodeUtf8With) import Data.Text.Encoding.Error (lenientDecode) import Network.URI (parseURI) import Database.Persist.Sql (PersistField, PersistFieldSql (..)) +#if MIN_VERSION_persistent(2,5,0) import Database.Persist (Entity (..), SqlType (SqlString), PersistRecordBackend, PersistQueryRead) +#else +import Database.Persist (Entity (..), SqlType (SqlString)) +#endif import Text.HTML.SanitizeXSS (sanitizeBalance) import Control.Monad (when, unless) import Data.Either (partitionEithers) @@ -646,6 +650,7 @@ optionsEnum = optionsPairs $ map (\x -> (pack $ show x, x)) [minBound..maxBound] -- > <$> areq (selectField countries) "Which country do you live in?" Nothing -- > where -- > countries = optionsPersist [] [Asc CountryName] countryName +#if MIN_VERSION_persistent(2,5,0) optionsPersist :: ( YesodPersist site , PersistQueryRead backend , PathPiece (Key a) @@ -657,6 +662,18 @@ optionsPersist :: ( YesodPersist site -> [SelectOpt a] -> (a -> msg) -> HandlerT site IO (OptionList (Entity a)) +#else +optionsPersist :: ( YesodPersist site, PersistEntity a + , PersistQuery (PersistEntityBackend a) + , PathPiece (Key a) + , RenderMessage site msg + , YesodPersistBackend site ~ PersistEntityBackend a + ) + => [Filter a] + -> [SelectOpt a] + -> (a -> msg) + -> HandlerT site IO (OptionList (Entity a)) +#endif optionsPersist filts ords toDisplay = fmap mkOptionList $ do mr <- getMessageRender pairs <- runDB $ selectList filts ords @@ -670,6 +687,7 @@ optionsPersist filts ords toDisplay = fmap mkOptionList $ do -- the entire 'Entity'. -- -- Since 1.3.2 +#if MIN_VERSION_persistent(2,5,0) optionsPersistKey :: (YesodPersist site , PersistQueryRead backend @@ -682,6 +700,20 @@ optionsPersistKey -> [SelectOpt a] -> (a -> msg) -> HandlerT site IO (OptionList (Key a)) +#else +optionsPersistKey + :: (YesodPersist site + , PersistEntity a + , PersistQuery (PersistEntityBackend a) + , PathPiece (Key a) + , RenderMessage site msg + , YesodPersistBackend site ~ PersistEntityBackend a + ) + => [Filter a] + -> [SelectOpt a] + -> (a -> msg) + -> HandlerT site IO (OptionList (Key a)) +#endif optionsPersistKey filts ords toDisplay = fmap mkOptionList $ do mr <- getMessageRender diff --git a/yesod-persistent/Yesod/Persist/Core.hs b/yesod-persistent/Yesod/Persist/Core.hs index 6cde856d..2b6904f6 100644 --- a/yesod-persistent/Yesod/Persist/Core.hs +++ b/yesod-persistent/Yesod/Persist/Core.hs @@ -81,9 +81,15 @@ newtype DBRunner site = DBRunner -- | 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 (persistBackend conn) (SQL.connPrepare $ persistBackend conn) @@ -125,9 +131,15 @@ respondSourceDB :: YesodPersistRunner site 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 @@ -136,9 +148,15 @@ get404 key = do -- | 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 diff --git a/yesod-persistent/yesod-persistent.cabal b/yesod-persistent/yesod-persistent.cabal index 3054a1d6..f32221a3 100644 --- a/yesod-persistent/yesod-persistent.cabal +++ b/yesod-persistent/yesod-persistent.cabal @@ -16,7 +16,7 @@ extra-source-files: README.md ChangeLog.md library build-depends: base >= 4 && < 5 , yesod-core >= 1.4.0 && < 1.5 - , persistent >= 2.5 && < 2.6 + , persistent >= 2.1 && < 2.6 , persistent-template >= 2.1 && < 2.2 , transformers >= 0.2.2 , blaze-builder