persistent-template 2.1.3.7 → 2.1.4
raw patch · 3 files changed
+14/−4 lines, 3 filesdep +http-api-datadep ~persistentPVP ok
version bump matches the API change (PVP)
Dependencies added: http-api-data
Dependency ranges changed: persistent
API changes (from Hackage documentation)
Files
- ChangeLog.md +4/−0
- Database/Persist/TH.hs +8/−3
- persistent-template.cabal +2/−1
ChangeLog.md view
@@ -1,3 +1,7 @@+## 2.1.4++support http-api-data for url serialization+ ## 2.1.3.3 By default explicitly use Int64 for foreign key references.
Database/Persist/TH.hs view
@@ -71,7 +71,8 @@ import Control.Applicative (pure, (<$>), (<*>)) import Database.Persist.Sql (sqlType) import Data.Proxy (Proxy (Proxy))-import Web.PathPieces (PathPiece, toPathPiece, fromPathPiece)+import Web.PathPieces (PathPiece(..))+import Web.HttpApiData (ToHttpApiData(..), FromHttpApiData(..), parseUrlPieceMaybe) import GHC.Generics (Generic) import qualified Data.Text.Encoding as TE @@ -669,7 +670,7 @@ -- | declare the key type and associated instances--- a PathPiece instance is only generated for a Key with one field+-- @'PathPiece'@, @'ToHttpApiData'@ and @'FromHttpApiData'@ instances are only generated for a Key with one field mkKeyTypeDec :: MkPersistSettings -> EntityDef -> Q (Dec, [Dec]) mkKeyTypeDec mps t = do (instDecs, i) <-@@ -683,7 +684,7 @@ then do pfDec <- pfInstD return (pfDec, [''Show, ''Read, ''Eq, ''Ord, ''Generic]) else do- let allInstances = [''Show, ''Read, ''Eq, ''Ord, ''PathPiece, ''PersistField, ''PersistFieldSql, ''ToJSON, ''FromJSON]+ let allInstances = [''Show, ''Read, ''Eq, ''Ord, ''PathPiece, ''ToHttpApiData, ''FromHttpApiData, ''PersistField, ''PersistFieldSql, ''ToJSON, ''FromJSON] if customKeyType then return ([], allInstances) else do@@ -751,6 +752,10 @@ compare x y = compare ($(return unKeyE) x) ($(return unKeyE) y)+ instance ToHttpApiData (BackendKey $(pure backendT)) => ToHttpApiData (Key $(pure recordType)) where+ toUrlPiece = toUrlPiece . $(return unKeyE)+ instance FromHttpApiData (BackendKey $(pure backendT)) => FromHttpApiData(Key $(pure recordType)) where+ parseUrlPiece = fmap $(return keyConE) . parseUrlPiece instance PathPiece (BackendKey $(pure backendT)) => PathPiece (Key $(pure recordType)) where toPathPiece = toPathPiece . $(return unKeyE) fromPathPiece = fmap $(return keyConE) . fromPathPiece
persistent-template.cabal view
@@ -1,5 +1,5 @@ name: persistent-template-version: 2.1.3.7+version: 2.1.4 license: MIT license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>@@ -29,6 +29,7 @@ , unordered-containers , tagged , path-pieces+ , http-api-data >= 0.2 && < 0.3 , ghc-prim exposed-modules: Database.Persist.TH ghc-options: -Wall