persistent-template 2.5.1 → 2.5.1.1
raw patch · 3 files changed
+15/−3 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +4/−0
- Database/Persist/TH.hs +10/−2
- persistent-template.cabal +1/−1
ChangeLog.md view
@@ -1,3 +1,7 @@+## 2.5.0.1++* workaround TH bug in GHC 7.10+ ## 2.5 * read/write typeclass split
Database/Persist/TH.hs view
@@ -81,6 +81,14 @@ import GHC.Generics (Generic) import qualified Data.Text.Encoding as TE +-- | This special-cases "type_" and strips out its underscore. When+-- used for JSON serialization and deserialization, it works around+-- <https://github.com/yesodweb/persistent/issues/412>+unHaskellNameForJSON :: HaskellName -> Text+unHaskellNameForJSON = fixTypeUnderscore . unHaskellName+ where fixTypeUnderscore "type_" = "type"+ fixTypeUnderscore name = name+ -- | Converts a quasi-quoted syntax into a list of entity definitions, to be -- used as input to the template haskell generation code (mkPersist). persistWith :: PersistSettings -> QuasiQuoter@@ -1534,7 +1542,7 @@ (objectE `AppE` ListE pairs) pairs = zipWith toPair (entityFields def) xs toPair f x = InfixE- (Just (packE `AppE` LitE (StringL $ unpack $ unHaskellName $ fieldHaskell f)))+ (Just (packE `AppE` LitE (StringL $ unpack $ unHaskellNameForJSON $ fieldHaskell f))) dotEqualE (Just $ VarE x) fromJSONI = typeInstanceD ''FromJSON (mpsGeneric mps) typ [parseJSON']@@ -1551,7 +1559,7 @@ toPull f = InfixE (Just $ VarE obj) (if maybeNullable f then dotColonQE else dotColonE)- (Just $ AppE packE $ LitE $ StringL $ unpack $ unHaskellName $ fieldHaskell f)+ (Just $ AppE packE $ LitE $ StringL $ unpack $ unHaskellNameForJSON $ fieldHaskell f) case mpsEntityJSON mps of Nothing -> return [toJSONI, fromJSONI] Just entityJSON -> do
persistent-template.cabal view
@@ -1,5 +1,5 @@ name: persistent-template-version: 2.5.1+version: 2.5.1.1 license: MIT license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>