Hello community, here is the log from the commit of package ghc-persistent-template for openSUSE:Factory checked in at 2019-08-13 13:15:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-persistent-template (Old) and /work/SRC/openSUSE:Factory/.ghc-persistent-template.new.9556 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-persistent-template" Tue Aug 13 13:15:18 2019 rev:19 rq:721034 version:2.7.2 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-persistent-template/ghc-persistent-template.changes 2019-05-12 11:36:14.838370263 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-persistent-template.new.9556/ghc-persistent-template.changes 2019-08-13 13:15:21.041504501 +0200 @@ -1,0 +2,9 @@ +Thu Jul 18 08:17:38 UTC 2019 - psim...@suse.com + +- Update persistent-template to version 2.7.2. + ## 2.7.2 + + * Expose the knot tying logic of `parseReferences` so that users can build + migrations from independently define entities at runtime [#932](https://github.com/yesodweb/persistent/pull/932) + +------------------------------------------------------------------- Old: ---- persistent-template-2.7.1.tar.gz New: ---- persistent-template-2.7.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-persistent-template.spec ++++++ --- /var/tmp/diff_new_pack.MBYAOt/_old 2019-08-13 13:15:21.493504396 +0200 +++ /var/tmp/diff_new_pack.MBYAOt/_new 2019-08-13 13:15:21.493504396 +0200 @@ -19,7 +19,7 @@ %global pkg_name persistent-template %bcond_with tests Name: ghc-%{pkg_name} -Version: 2.7.1 +Version: 2.7.2 Release: 0 Summary: Type-safe, non-relational, multi-backend persistence License: MIT ++++++ persistent-template-2.7.1.tar.gz -> persistent-template-2.7.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/persistent-template-2.7.1/ChangeLog.md new/persistent-template-2.7.2/ChangeLog.md --- old/persistent-template-2.7.1/ChangeLog.md 2019-05-07 03:35:33.000000000 +0200 +++ new/persistent-template-2.7.2/ChangeLog.md 2019-07-17 15:42:19.000000000 +0200 @@ -1,3 +1,8 @@ +## 2.7.2 + +* Expose the knot tying logic of `parseReferences` so that users can build + migrations from independently define entities at runtime [#932](https://github.com/yesodweb/persistent/pull/932) + ## 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) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/persistent-template-2.7.1/Database/Persist/TH.hs new/persistent-template-2.7.2/Database/Persist/TH.hs --- old/persistent-template-2.7.1/Database/Persist/TH.hs 2019-05-07 03:35:33.000000000 +0200 +++ new/persistent-template-2.7.2/Database/Persist/TH.hs 2019-07-17 15:42:19.000000000 +0200 @@ -40,6 +40,7 @@ -- * Internal , lensPTH , parseReferences + , embedEntityDefs , AtLeastOneUniqueKey(..) , OnlyOneUniqueKey(..) ) where @@ -164,14 +165,20 @@ s <- qRunIO $ TIO.hGetContents h return s --- calls parse to Quasi.parse individual entities in isolation --- afterwards, sets references to other entities --- | @since 2.5.3 -parseReferences :: PersistSettings -> Text -> Q Exp -parseReferences ps s = lift $ - map (mkEntityDefSqlTypeExp embedEntityMap entMap) noCycleEnts +-- Takes a list of (potentially) independently defined entities and properly +-- links all foreign keys to reference the right 'EntityDef', tying the knot +-- between entities. +-- +-- Allows users to define entities indepedently or in separate modules and then +-- fix the cross-references between them at runtime to create a 'Migration'. +-- +-- @since 2.7.2 +embedEntityDefs :: [EntityDef] -> [EntityDef] +embedEntityDefs = snd . embedEntityDefsMap + +embedEntityDefsMap :: [EntityDef] -> (M.Map HaskellName EmbedEntityDef, [EntityDef]) +embedEntityDefsMap rawEnts = (embedEntityMap, noCycleEnts) where - entMap = M.fromList $ map (\ent -> (entityHaskell ent, ent)) noCycleEnts noCycleEnts = map breakCycleEnt entsWithEmbeds -- every EntityDef could reference each-other (as an EmbedRef) -- let Haskell tie the knot @@ -180,7 +187,6 @@ setEmbedEntity ent = ent { entityFields = map (setEmbedField (entityHaskell ent) embedEntityMap) $ entityFields ent } - rawEnts = parse ps s -- self references are already broken -- look at every emFieldEmbed to see if it refers to an already seen HaskellName @@ -208,6 +214,15 @@ where membed = emFieldEmbed emf +-- calls parse to Quasi.parse individual entities in isolation +-- afterwards, sets references to other entities +-- | @since 2.5.3 +parseReferences :: PersistSettings -> Text -> Q Exp +parseReferences ps s = lift $ + map (mkEntityDefSqlTypeExp embedEntityMap entMap) noCycleEnts + where + (embedEntityMap, noCycleEnts) = embedEntityDefsMap $ parse ps s + entMap = M.fromList $ map (\ent -> (entityHaskell ent, ent)) noCycleEnts stripId :: FieldType -> Maybe Text diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/persistent-template-2.7.1/persistent-template.cabal new/persistent-template-2.7.2/persistent-template.cabal --- old/persistent-template-2.7.1/persistent-template.cabal 2019-05-07 03:35:33.000000000 +0200 +++ new/persistent-template-2.7.2/persistent-template.cabal 2019-07-17 15:42:19.000000000 +0200 @@ -1,5 +1,5 @@ name: persistent-template -version: 2.7.1 +version: 2.7.2 license: MIT license-file: LICENSE author: Michael Snoyman <mich...@snoyman.com>