diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2265e9ec..c328b031 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,6 +22,7 @@ jobs: - "--resolver lts-11" - "--stack-yaml stack-persistent-211.yaml" - "--stack-yaml stack-persistent-212.yaml" + - "--stack-yaml stack-persistent-213.yaml" # Bugs in GHC make it crash too often to be worth running exclude: - os: windows-latest diff --git a/.gitignore b/.gitignore index 42e81982..8f84fbea 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ tarballs/ # OS X .DS_Store +*.yaml.lock diff --git a/stack-persistent-213.yaml b/stack-persistent-213.yaml new file mode 100644 index 00000000..c90d12e7 --- /dev/null +++ b/stack-persistent-213.yaml @@ -0,0 +1,23 @@ +resolver: nightly-2021-03-31 +packages: +- ./yesod-core +- ./yesod-static +- ./yesod-persistent +- ./yesod-newsfeed +- ./yesod-form +- ./yesod-form-multi +- ./yesod-auth +- ./yesod-auth-oauth +- ./yesod-sitemap +- ./yesod-test +- ./yesod-bin +- ./yesod +- ./yesod-eventsource +- ./yesod-websockets +extra-deps: +- lift-type-0.1.0.1 +- persistent-2.13.0.0 +- persistent-mysql-2.13.0.0 +- persistent-sqlite-2.13.0.0 +- persistent-postgresql-2.13.0.0 +- persistent-template-2.12.0.0 diff --git a/yesod-persistent/ChangeLog.md b/yesod-persistent/ChangeLog.md index a8c8dad1..52286010 100644 --- a/yesod-persistent/ChangeLog.md +++ b/yesod-persistent/ChangeLog.md @@ -1,5 +1,9 @@ # ChangeLog for yesod-persistent +## 1.6.0.7 + +* Add support for persistent 2.13. [#1723](https://github.com/yesodweb/yesod/pull/1723) + ## 1.6.0.6 * Add support for persistent 2.12 diff --git a/yesod-persistent/Yesod/Persist/Core.hs b/yesod-persistent/Yesod/Persist/Core.hs index b7c82baf..6a671ca7 100644 --- a/yesod-persistent/Yesod/Persist/Core.hs +++ b/yesod-persistent/Yesod/Persist/Core.hs @@ -25,6 +25,7 @@ module Yesod.Persist.Core 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) @@ -33,6 +34,9 @@ import Control.Monad.Trans.Resource import Control.Exception (throwIO) import Yesod.Core.Types (HandlerContents (HCError)) import qualified Database.Persist.Sql as SQL +#if MIN_VERSION_persistent(2,13,0) +import qualified Database.Persist.SqlBackend.Internal as SQL +#endif unSqlPersistT :: a -> a unSqlPersistT = id @@ -197,7 +201,11 @@ insert400 datum = do case conflict of Just unique -> #if MIN_VERSION_persistent(2, 12, 0) - badRequest' $ map (unFieldNameHS . fst) $ persistUniqueToFieldNames unique +-- 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 #else badRequest' $ map (unHaskellName . fst) $ persistUniqueToFieldNames unique #endif diff --git a/yesod-persistent/yesod-persistent.cabal b/yesod-persistent/yesod-persistent.cabal index 5bd21f5c..b9ca9fff 100644 --- a/yesod-persistent/yesod-persistent.cabal +++ b/yesod-persistent/yesod-persistent.cabal @@ -1,6 +1,6 @@ cabal-version: >= 1.10 name: yesod-persistent -version: 1.6.0.6 +version: 1.6.0.7 license: MIT license-file: LICENSE author: Michael Snoyman