packages feed

persistent 2.1.2 → 2.1.3

raw patch · 2 files changed

+27/−14 lines, 2 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Database.Persist.Types: toEmbedFieldDef :: FieldDef -> EmbedFieldDef
+ Database.Persist.Types: SelfReference :: ReferenceDef
+ Database.Persist.Types: emFieldCycle :: EmbedFieldDef -> Maybe HaskellName
- Database.Persist.Types: EmbedFieldDef :: !DBName -> Maybe EmbedEntityDef -> EmbedFieldDef
+ Database.Persist.Types: EmbedFieldDef :: !DBName -> Maybe EmbedEntityDef -> Maybe HaskellName -> EmbedFieldDef

Files

Database/Persist/Types/Base.hs view
@@ -96,6 +96,7 @@                 | NotNullable                   deriving (Eq, Show) + -- | The reason why a field is 'nullable' is very important.  A -- field that is nullable because of a @Maybe@ tag will have its -- type changed from @A@ to @Maybe A@.  OTOH, a field that is@@ -157,9 +158,12 @@ -- 2) single field -- 3) embedded data ReferenceDef = NoReference-                  | ForeignRef !HaskellName !FieldType -- ^ A ForeignRef has a late binding to the EntityDef it references via HaskellName and has the Haskell type of the foreign key in the form of FieldType+                  | ForeignRef !HaskellName !FieldType+                    -- ^ A ForeignRef has a late binding to the EntityDef it references via HaskellName and has the Haskell type of the foreign key in the form of FieldType                   | EmbedRef EmbedEntityDef                   | CompositeRef CompositeDef+                  | SelfReference+                    -- ^ A SelfReference stops an immediate cycle which causes non-termination at compile-time (issue #311).                   deriving (Show, Eq, Read, Ord)  -- | An EmbedEntityDef is the same as an EntityDef@@ -176,22 +180,31 @@ data EmbedFieldDef = EmbedFieldDef     { emFieldDB       :: !DBName     , emFieldEmbed :: Maybe EmbedEntityDef+    , emFieldCycle :: Maybe HaskellName+    -- ^ 'emFieldEmbed' can create a cycle (issue #311)+    -- when a cycle is detected, 'emFieldEmbed' will be Nothing+    -- and 'emFieldCycle' will be Just     }     deriving (Show, Eq, Read, Ord)  toEmbedEntityDef :: EntityDef -> EmbedEntityDef-toEmbedEntityDef ent = EmbedEntityDef-  { embeddedHaskell = entityHaskell ent-  , embeddedFields = map toEmbedFieldDef $ entityFields ent-  }--toEmbedFieldDef :: FieldDef -> EmbedFieldDef-toEmbedFieldDef field =-  EmbedFieldDef { emFieldDB       = fieldDB field-                   , emFieldEmbed = case fieldReference field of-                       EmbedRef em -> Just em-                       _ -> Nothing-                   }+toEmbedEntityDef ent = embDef+  where+    embDef = EmbedEntityDef+      { embeddedHaskell = entityHaskell ent+      , embeddedFields = map toEmbedFieldDef $ entityFields ent+      }+    toEmbedFieldDef :: FieldDef -> EmbedFieldDef+    toEmbedFieldDef field =+      EmbedFieldDef { emFieldDB       = fieldDB field+                    , emFieldEmbed = case fieldReference field of+                        EmbedRef em -> Just em+                        SelfReference -> Just embDef+                        _ -> Nothing+                    , emFieldCycle = case fieldReference field of+                        SelfReference -> Just $ entityHaskell ent+                        _ -> Nothing+                    }  data UniqueDef = UniqueDef     { uniqueHaskell :: !HaskellName
persistent.cabal view
@@ -1,5 +1,5 @@ name:            persistent-version:         2.1.2+version:         2.1.3 license:         MIT license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>