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

fix: camelize when prefix is camelized already #343

Merged
merged 2 commits into from
Nov 2, 2024

Conversation

rodrigues
Copy link
Contributor

This PR fixes a problem when payload relationship is already camelized:

In the POST, when you receive as payload:

%{
  type: "example-resource",
  attributes: %{...},
  relationships: %{
    generalManagerProfile: %{data: %{id: manager_id, type: "profiles"}}
  }
}

params will resolve to:

%{"generalmanagerprofileId" => 139981}

with this fix, it resolves correctly to generalManagerProfileId, and with the UnderscoreParameters plug, becomes general_manager_profile_id.

@rodrigues rodrigues requested a review from a team as a code owner October 28, 2024 16:07
Copy link
Member

@mattpolzin mattpolzin left a comment

Choose a reason for hiding this comment

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

This looks like a good idea to me, but I think it could be argued to regress on something that admittedly is not strictly defined behavior: ThisThing used to be transformed into something starting with a lower case t but won't anymore, right?

@rodrigues
Copy link
Contributor Author

good point @mattpolzin, thanks, I've pushed a change to address this scenario too:

iex> camelize("PascalLambda_id")
      "pascalLambdaId"

@mattpolzin mattpolzin merged commit 3b5cd90 into beam-community:main Nov 2, 2024
8 checks passed
@rodrigues rodrigues deleted the fix_camelize branch November 2, 2024 21:12
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