-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support NoFieldSelectors and DuplicateRecordFields (#1379)
* Support NoFieldSelectors and DuplicateRecordFields * Getters are defined in terms of explicit record pattern match instead of a field selector function * It defines record updates verbosely in order to disambiguate duplicate fields * Update ChangeLog * add NoFieldSelectorsSpec
- Loading branch information
Showing
5 changed files
with
84 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
persistent/test/Database/Persist/TH/NoFieldSelectorsSpec.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{-# LANGUAGE CPP #-} | ||
#if __GLASGOW_HASKELL__ >= 902 | ||
{-# LANGUAGE NoFieldSelectors #-} | ||
{-# LANGUAGE DuplicateRecordFields #-} | ||
#endif | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-# LANGUAGE QuasiQuotes #-} | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE DerivingStrategies #-} | ||
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
{-# LANGUAGE StandaloneDeriving #-} | ||
{-# LANGUAGE UndecidableInstances #-} | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
|
||
module Database.Persist.TH.NoFieldSelectorsSpec where | ||
|
||
import TemplateTestImports | ||
|
||
#if __GLASGOW_HASKELL__ >= 902 | ||
|
||
mkPersist sqlSettings {mpsFieldLabelModifier = const id} [persistLowerCase| | ||
User | ||
name Text | ||
|
||
Team | ||
name Text | ||
|] | ||
|
||
spec :: Spec | ||
spec = it "compiles" True | ||
|
||
#else | ||
|
||
spec :: Spec | ||
spec = do | ||
it "only works with GHC 9.2 or greater" $ do | ||
pendingWith "only works with GHC 9.2 or greater" | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters