yesod-persistent 1.6.0.8 → 1.6.0.9
raw patch · 4 files changed
+47/−63 lines, 4 filesdep ~yesod-corePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: yesod-core
API changes (from Hackage documentation)
- Yesod.Persist.Core: type family YesodPersistBackend site;
+ Yesod.Persist.Core: type YesodPersistBackend site;
- Yesod.Persist.Core: DBRunner :: (forall a. YesodDB site a -> HandlerFor site a) -> DBRunner site
+ Yesod.Persist.Core: DBRunner :: (forall a. () => YesodDB site a -> HandlerFor site a) -> DBRunner site
- Yesod.Persist.Core: [runDBRunner] :: DBRunner site -> forall a. YesodDB site a -> HandlerFor site a
+ Yesod.Persist.Core: [runDBRunner] :: DBRunner site -> forall a. () => YesodDB site a -> HandlerFor site a
- Yesod.Persist.Core: class Monad (YesodDB site) => YesodPersist site where {
+ Yesod.Persist.Core: class Monad YesodDB site => YesodPersist site where {
- Yesod.Persist.Core: get404 :: (MonadIO m, PersistStoreRead backend, PersistRecordBackend val backend) => Key val -> ReaderT backend m val
+ Yesod.Persist.Core: get404 :: forall (m :: Type -> Type) backend val. (MonadIO m, PersistStoreRead backend, PersistRecordBackend val backend) => Key val -> ReaderT backend m val
- Yesod.Persist.Core: getBy404 :: (PersistUniqueRead backend, PersistRecordBackend val backend, MonadIO m) => Unique val -> ReaderT backend m (Entity val)
+ Yesod.Persist.Core: getBy404 :: forall backend val (m :: Type -> Type). (PersistUniqueRead backend, PersistRecordBackend val backend, MonadIO m) => Unique val -> ReaderT backend m (Entity val)
- Yesod.Persist.Core: insert400 :: (MonadIO m, PersistUniqueWrite backend, PersistRecordBackend val backend, SafeToInsert val) => val -> ReaderT backend m (Key val)
+ Yesod.Persist.Core: insert400 :: forall (m :: Type -> Type) backend val. (MonadIO m, PersistUniqueWrite backend, PersistRecordBackend val backend, SafeToInsert val) => val -> ReaderT backend m (Key val)
- Yesod.Persist.Core: insert400_ :: (MonadIO m, PersistUniqueWrite backend, PersistRecordBackend val backend, SafeToInsert val) => val -> ReaderT backend m ()
+ Yesod.Persist.Core: insert400_ :: forall (m :: Type -> Type) backend val. (MonadIO m, PersistUniqueWrite backend, PersistRecordBackend val backend, SafeToInsert val) => val -> ReaderT backend m ()
- Yesod.Persist.Core: type YesodDB site = ReaderT (YesodPersistBackend site) (HandlerFor site)
+ Yesod.Persist.Core: type YesodDB site = ReaderT YesodPersistBackend site HandlerFor site
Files
- ChangeLog.md +4/−0
- Yesod/Persist/Core.hs +28/−55
- test/Yesod/PersistSpec.hs +12/−6
- yesod-persistent.cabal +3/−2
ChangeLog.md view
@@ -1,5 +1,9 @@ # ChangeLog for yesod-persistent +## 1.6.0.9++* Support `yesod-core` 1.7+ ## 1.6.0.8 * Add support for `persistent-2.14` [#1706](https://github.com/yesodweb/yesod/pull/1760)
Yesod/Persist/Core.hs view
@@ -1,9 +1,11 @@ {-# LANGUAGE ConstraintKinds #-}-{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE RankNTypes #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -fno-warn-orphans #-}+ -- | Defines the core functionality of this package. This package is -- distinguished from Yesod.Persist in that the latter additionally exports the -- persistent modules themselves.@@ -25,7 +27,6 @@ import Database.Persist import Control.Monad.Trans.Reader (ReaderT, runReaderT) -import Data.Foldable (toList) import Yesod.Core import Data.Conduit import Blaze.ByteString.Builder (Builder)@@ -35,11 +36,9 @@ import Yesod.Core.Types (HandlerContents (HCError)) import qualified Database.Persist.Sql as SQL #if MIN_VERSION_persistent(2,13,0)+import Data.List.NonEmpty (toList) import qualified Database.Persist.SqlBackend.Internal as SQL #endif-#if MIN_VERSION_persistent(2,14,0)-import Database.Persist.Class.PersistEntity-#endif unSqlPersistT :: a -> a unSqlPersistT = id@@ -99,15 +98,9 @@ -- | 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) -> HandlerFor site (DBRunner site, HandlerFor site ())-#else-defaultGetDBRunner :: YesodPersistBackend site ~ SQL.SqlBackend- => (site -> Pool SQL.SqlBackend)- -> HandlerFor site (DBRunner site, HandlerFor site ())-#endif defaultGetDBRunner getPool = do pool <- fmap getPool getYesod let withPrep conn f = f (persistBackend conn) (SQL.getStmtConn $ persistBackend conn)@@ -153,15 +146,9 @@ 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, PersistStoreRead 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@@ -170,15 +157,9 @@ -- | 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 :: (PersistUniqueRead 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@@ -190,54 +171,46 @@ -- is violated. -- -- @since 1.4.1-#if MIN_VERSION_persistent(2,14,0) insert400- :: (MonadIO m, PersistUniqueWrite backend, PersistRecordBackend val backend, SafeToInsert val)- => val- -> ReaderT backend m (Key val)-#elif MIN_VERSION_persistent(2,5,0)-insert400- :: (MonadIO m, PersistUniqueWrite backend, PersistRecordBackend val backend)+ :: ( MonadIO m+ , PersistUniqueWrite backend+ , PersistRecordBackend val backend+#if MIN_VERSION_persistent(2,14,0)+ , SafeToInsert val+#endif+ ) => val -> ReaderT backend m (Key val)-#else-insert400- :: (MonadIO m, PersistUnique (PersistEntityBackend val), PersistEntity val)- => val- -> ReaderT (PersistEntityBackend val) m (Key val)-#endif insert400 datum = do conflict <- checkUnique datum case conflict of Just unique ->-#if MIN_VERSION_persistent(2, 12, 0)--- toList is called here because persistent-2.13 changed this--- to a nonempty list. for versions of persistent prior to 2.13, toList--- will be a no-op. for persistent-2.13, it'll convert the NonEmptyList to--- a List.- badRequest' $ map (unFieldNameHS . fst) $ toList $ persistUniqueToFieldNames unique+ badRequest' $ map (getName . fst) $ mkList $ persistUniqueToFieldNames unique+ Nothing -> insert datum+ where+#if MIN_VERSION_persistent(2,12,0)+ getName = unFieldNameHS #else- badRequest' $ map (unHaskellName . fst) $ persistUniqueToFieldNames unique+ getName = unHaskellName #endif- Nothing -> insert datum+#if MIN_VERSION_persistent(2,13,0)+ mkList = toList+#else+ mkList = id+#endif -- | Same as 'insert400', but doesn’t return a key. -- -- @since 1.4.1+insert400_ :: ( MonadIO m+ , PersistUniqueWrite backend+ , PersistRecordBackend val backend #if MIN_VERSION_persistent(2,14,0)-insert400_ :: (MonadIO m, PersistUniqueWrite backend, PersistRecordBackend val backend, SafeToInsert val)- => val- -> ReaderT backend m ()--#elif MIN_VERSION_persistent(2,5,0)-insert400_ :: (MonadIO m, PersistUniqueWrite backend, PersistRecordBackend val backend)+ , SafeToInsert val+#endif+ ) => val -> ReaderT backend m ()-#else-insert400_ :: (MonadIO m, PersistUnique (PersistEntityBackend val), PersistEntity val)- => val- -> ReaderT (PersistEntityBackend val) m ()-#endif insert400_ datum = insert400 datum >> return () -- | Should be equivalent to @lift . notFound@, but there's an apparent bug in
test/Yesod/PersistSpec.hs view
@@ -1,13 +1,19 @@-{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE DataKinds #-}-{-# LANGUAGE OverloadedStrings, TemplateHaskell, QuasiQuotes, TypeFamilies #-}-{-# LANGUAGE EmptyDataDecls, FlexibleContexts, GADTs #-}+{-# LANGUAGE DerivingStrategies #-}+{-# LANGUAGE EmptyDataDecls #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE GADTs #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE CPP #-}-{-# LANGUAGE UndecidableInstances #-}-{-# LANGUAGE DerivingStrategies #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE UndecidableInstances #-}+ module Yesod.PersistSpec where import Test.Hspec
yesod-persistent.cabal view
@@ -1,6 +1,6 @@ cabal-version: >= 1.10 name: yesod-persistent-version: 1.6.0.8+version: 1.6.0.9 license: MIT license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>@@ -16,7 +16,7 @@ library default-language: Haskell2010 build-depends: base >= 4.10 && < 5- , yesod-core >= 1.6 && < 1.7+ , yesod-core >= 1.6 && < 1.8 , persistent >= 2.8 , persistent-template >= 2.1 , transformers >= 0.2.2@@ -34,6 +34,7 @@ main-is: Spec.hs hs-source-dirs: test other-modules: Yesod.PersistSpec+ build-tool-depends: hspec-discover:hspec-discover build-depends: base , hspec , wai-extra