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

Camel/Snake case inconsistency in Pledge class is breaking Java Spring Integration #24

Open
decmurphy opened this issue Sep 13, 2018 · 3 comments

Comments

@decmurphy
Copy link

decmurphy commented Sep 13, 2018

I'm trying to make API calls to get all of my campaigns pledges and then cache them for some time on my server, so as to avoid querying the Patreon servers too much. I'm storing the JSON results of

fetchAllPledges(String campaignId)
and the Rewards subsection of
fetchCampaigns()

in a MongoDB database, and using Spring Repositories to save to and to read from the database.

Spring makes assumptions about variable names based in Java convention. If a field name is amount_cents, it will call a getter getAmount_cents(). If that field name is amountCents, it will call getAmountCents(), and so on.

For some reason, the member variables of the Pledge class are camelCase, even though the variables entered into the constructor are snake_case. This isn't the situation in, for example, the Reward class where both the member variables and the constructor parameters are in snake_case and Spring performs perfectly.

Petition to modify the member variables of Pledge to use a consistent case scheme. Spring doesn't care which scheme is used, as long as there is consistency.

@nperickson
Copy link

Hey @murphd37,

I talked with the team and it sounds like what you're asking for is already possible without us needing to change anything. A suggestion made by one of my engineers was that you could wrap our whole class in bean with names of your choosing. That should fix it without needing to reconfigure Spring.

@decmurphy
Copy link
Author

Hi @nperickson,

Thanks for the response! That's actually what I'm doing, believe it or not, and yes it works. So my issue is far from a burning one. But it's more of a workaround than a fix, don't you agree?

I wouldn't say that changing the case of some private variables needs an immediate fix and deploy, because it's obviously not critical. But it seems like such a trivial task that will not only confirm to Java conventions but also make easier the life of anyone trying to integrate this project with a Java Spring project.

I'm happy to submit a PR for this, if you think there's a possibility of it being merged.

@decmurphy
Copy link
Author

Hi @nperickson - any thoughts on the above?
As I say, I'm happy to submit a PR.

Thanks!

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

No branches or pull requests

2 participants