Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MkPersistSettings option for preserve CamelCase style of composite keys #1421

Merged
merged 7 commits into from
Aug 24, 2022

Conversation

sergesku
Copy link
Contributor

@sergesku sergesku commented Aug 24, 2022

Before submitting your PR, check that you've:

  • Documented new APIs with Haddock markup
  • Added @since declarations to the Haddock
  • Ran stylish-haskell on any changed files.
  • Adhered to the code style (see the .editorconfig file for details)

After submitting your PR:

  • Update the Changelog.md file with a link to your PR
  • Bumped the version number if there isn't an (unreleased) on the Changelog
  • Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts)

In accordance with the #1420 , this PR adds an additional field mpsCamelCaseCompositeKeySelector to the MkPersistSettings.
This field can be used to determine whether the entity composite key selectors should continue to match the Legacy style (companyUserKeycompanyId) or match the CameCase style (companyUserKeyCompanyId).

Copy link
Collaborator

@parsonsmatt parsonsmatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you!

A few notes on the version number. I think I can commit that myself and get this meged+released soon.

persistent/persistent.cabal Outdated Show resolved Hide resolved
persistent/Database/Persist/TH.hs Outdated Show resolved Hide resolved
Comment on lines +43 to +62
spec :: Spec
spec = describe "CompositeKeyStyleSpec" $ do
describe "mpsCamelCaseCompositeKeySelector is False" $ do
it "Should generate Legacy style key selectors" $ do
let key = CompanyUserLegacyStyleKey "cName" "uName"

constrFields (toConstr key)
`shouldBe`
[ "companyUserLegacyStyleKeycompanyName"
, "companyUserLegacyStyleKeyuserName"
]
describe "mpsCamelCaseCompositeKeySelector is True" $ do
it "Should generate CamelCase style key selectors" $ do
let key = CompanyUserCamelStyleKey "cName" "uName"

constrFields (toConstr key)
`shouldBe`
[ "companyUserCamelStyleKeyCompanyName"
, "companyUserCamelStyleKeyUserName"
]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very cool test!

Comment on lines +996 to +1000
-- ^ Should we generate composite key accessors in the correct CamelCase style.
--
-- If the 'mpsCamelCaseCompositeKeySelector' value is set to 'False',
-- then the field part of the accessor starts with the lowercase.
-- This is a legacy style.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doc comment is fantastic <3

persistent/ChangeLog.md Outdated Show resolved Hide resolved
persistent/ChangeLog.md Show resolved Hide resolved
@parsonsmatt parsonsmatt merged commit 04e40bb into yesodweb:master Aug 24, 2022
@parsonsmatt
Copy link
Collaborator

released!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants