Support persistent-2.13
This commit is contained in:
parent
2f8036c61f
commit
3224e8e6f1
1
.gitignore
vendored
1
.gitignore
vendored
@ -25,3 +25,4 @@ tarballs/
|
|||||||
|
|
||||||
# OS X
|
# OS X
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
*.yaml.lock
|
||||||
|
|||||||
25
stack-persistent-213.yaml
Normal file
25
stack-persistent-213.yaml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
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
|
||||||
|
- git: git@github.com:yesodweb/persistent
|
||||||
|
commit: 315ae91349ef4fbc2f4f2595cb7d3423e79ef80f
|
||||||
|
subdirs:
|
||||||
|
- persistent
|
||||||
|
- persistent-sqlite
|
||||||
|
- persistent-mysql
|
||||||
|
- persistent-postgresql
|
||||||
@ -25,6 +25,7 @@ module Yesod.Persist.Core
|
|||||||
import Database.Persist
|
import Database.Persist
|
||||||
import Control.Monad.Trans.Reader (ReaderT, runReaderT)
|
import Control.Monad.Trans.Reader (ReaderT, runReaderT)
|
||||||
|
|
||||||
|
import Data.Foldable (toList)
|
||||||
import Yesod.Core
|
import Yesod.Core
|
||||||
import Data.Conduit
|
import Data.Conduit
|
||||||
import Blaze.ByteString.Builder (Builder)
|
import Blaze.ByteString.Builder (Builder)
|
||||||
@ -33,6 +34,9 @@ import Control.Monad.Trans.Resource
|
|||||||
import Control.Exception (throwIO)
|
import Control.Exception (throwIO)
|
||||||
import Yesod.Core.Types (HandlerContents (HCError))
|
import Yesod.Core.Types (HandlerContents (HCError))
|
||||||
import qualified Database.Persist.Sql as SQL
|
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 :: a -> a
|
||||||
unSqlPersistT = id
|
unSqlPersistT = id
|
||||||
@ -197,7 +201,11 @@ insert400 datum = do
|
|||||||
case conflict of
|
case conflict of
|
||||||
Just unique ->
|
Just unique ->
|
||||||
#if MIN_VERSION_persistent(2, 12, 0)
|
#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
|
#else
|
||||||
badRequest' $ map (unHaskellName . fst) $ persistUniqueToFieldNames unique
|
badRequest' $ map (unHaskellName . fst) $ persistUniqueToFieldNames unique
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user