-
Notifications
You must be signed in to change notification settings - Fork 16
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
Create entry requires field name in camelCase #67
Comments
Hey, thanks for reporting the issue. I am looking into it. I will get back to you if I need more details. Cheers |
I encountered this issue completely upside down. Parameters of my content type are being converted to snake case after retrieving 🤦♂️ CONTENTFUL_CONTENT_TYPE = (
Client(CONTENTFUL_KEY).content_types(SPACE_ID, ENVIRONMENT).find(CONTENT_TYPE)
)
entry = CONTENTFUL_CONTENT_TYPE.entries().create("test", {"fields": {"paramOne": {"en-US": "one"}}})
entry.publish()
entry = CONTENTFUL_CONTENT_TYPE.entries().find("test")
print(entry.fields())
# {"id": "test", "param_one": "one"} |
Hi @martinezpl I am checking with the product team if there is any standard spec internally to name fields. I will let you know as soon as I know. Cheers. |
Hi @Toreno96 and @martinezpl, I've been looking into this issue more closely, and it appears that the inconsistency with Contentful's API can be easily resolved by converting the naming convention to camelCase. However, before implementing this change, I'd like to delve deeper into the reasoning behind the decision to use snake_case in the first place. Considering that the library already has an existing user base and changing to camelCase would break the current behavior, we need to exercise extra caution. We want to ensure that the benefits of the change outweigh the potential disruption it may cause for our users. I'll continue my investigation to gather more insights. Cheers |
@rubydog Thank you for looking into the issue. I appreciate you coming back to this.
I don't understand how that would work for my specific use-case, tho? The issue I've reported is that I wanted and expected to use snake_case instead of camelCase in the first place, so converting the naming convention to camelCase seem to be like quite the opposite of my need? Or did I misunderstand something? |
Thank you. @rubydog Working around that was not an issue (the SDK has utils for converting naming styles). |
Steps to reproduce
Create content model (e.g. "foo") with field
pg_rating
(multiple words in snake_case) in Contentful.Try to create a new entry:
Encountered behavior
An error is raised:
Expected behavior
Entry is created, the current value of its
pg_rating
field isvalue
.Workaround
When creating a new entry, field name has to be written in camelCase:
That's the underlying issue with API, not SDK, as I tried to make direct request to the API using httpie and it also returns an error:
Suggested solutions
Implement workaround in SDK
If it's easier to fix that here than in API.
Especially that the issue introduces inconsistency; during update it is actually not possible to use camelCase, snake_case is required there:
Document the issue
I found no info about how multiword field names are handled, neither in docs of SDK, nor in docs of API.
There's no example if user should use snake_case or camelCase, or what.
If it's non-trivial to implement a workaround in SDK or fix in API, then documenting it explicitly would be at least something.
The text was updated successfully, but these errors were encountered: