packages feed

persistent-template 2.7.0 → 2.7.1

raw patch · 3 files changed

+36/−1 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Database.Persist.TH: mkEntityDefList :: String -> [EntityDef] -> Q [Dec]

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+## 2.7.1++* Add the `mkEntityDefList` function to work around [#902](https://github.com/yesodweb/persistent/issues/902). [#904](https://github.com/yesodweb/persistent/pull/904)+ ## 2.7.0  * Depends on `persistent-2.10.0` which provides the `OnlyOneUniqueKey` and `AtLeastOneUniqueKey` classes. Automatically generates instances for these classes based on how many unique keys the entity definition gets. This changes requires `UndecidableInstances` to be enabled on each module that generates entity definitions. [#885](https://github.com/yesodweb/persistent/pull/885)
Database/Persist/TH.hs view
@@ -32,6 +32,7 @@     , mkMigrate     , mkSave     , mkDeleteCascade+    , mkEntityDefList     , share     , derivePersistField     , derivePersistFieldJSON@@ -1360,6 +1361,36 @@             [ FunD 'deleteCascade                 [normalClause [VarP key] (DoE stmts)]             ]++-- | Creates a declaration for the @['EntityDef']@ from the @persistent@+-- schema. This is necessary because the Persistent QuasiQuoter is unable+-- to know the correct type of ID fields, and assumes that they are all+-- Int64.+--+-- Provide this in the list you give to 'share', much like @'mkMigrate'@.+--+-- @+-- 'share' ['mkMigrate' "migrateAll", 'mkEntityDefList' "entityDefs"] [...]+-- @+--+-- @since 2.7.1+mkEntityDefList+    :: String+    -- ^ The name that will be given to the 'EntityDef' list.+    -> [EntityDef]+    -> Q [Dec]+mkEntityDefList entityList entityDefs = do+    let entityListName = mkName entityList+    edefs <- fmap ListE+        . forM entityDefs+        $ \(EntityDef { entityHaskell = HaskellName haskellName }) ->+            let entityType = conT (mkName (T.unpack haskellName))+             in [|entityDef (Proxy :: Proxy $(entityType))|]+    typ <- [t|[EntityDef]|]+    pure+        [ SigD entityListName typ+        , ValD (VarP entityListName) (NormalB edefs) []+        ]  mkUniqueKeys :: EntityDef -> Q Dec mkUniqueKeys def | entitySum def =
persistent-template.cabal view
@@ -1,5 +1,5 @@ name:            persistent-template-version:         2.7.0+version:         2.7.1 license:         MIT license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>