Skip to content

MkPersistSettings option for preserve CamelCase style of composite keys#1421

Merged
parsonsmatt merged 7 commits intoyesodweb:masterfrom
sergesku:composite-key-selectors
Aug 24, 2022
Merged

MkPersistSettings option for preserve CamelCase style of composite keys#1421
parsonsmatt merged 7 commits intoyesodweb:masterfrom
sergesku:composite-key-selectors

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.

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

@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.

2 participants