-
-
Notifications
You must be signed in to change notification settings - Fork 126
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
Naming convention: snake_case vs. camelCase #34
Comments
Good call Bobbie
Despite being REST idiomatic, I think there are some important benefits of snake_case:
It's easy to say to developers "our API uses snake_case", but harder to code snake<->camel just because of convention. I think at the moment we are mixing the two ( |
In general, I prefer consistent and predictable design at the cost of implementation complexity. In this case:
P.S. My biggest concern is breaking prod. How much interaction is there with |
yeah it's already used in prod so it will definitely break. The camel -> snake conversions will be safer because we aren't using query params, but we are using response keys/objects.
Probably not with the changes to production but regardless, we should prioritize the effort going forward over the effort now. Writing less code is always my number 1 concern, more than blindly following a convention. My gut is snake_case is going to save us a mountain of effort going forward, but I'll leave the final decision to you Side note, I used to always write snake-camel converters between my PG database and my API. When I started using postgREST I stopped doing that and it actually made things conceptually simpler - camel = code, snake = database. Also reduced my LOC. This convention isn't unheard of either, but not really necessary here. |
🎉 This issue has been resolved in version 0.10.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
@kiwicopple - is postgREST able to automatically convert from snake to camel and vice versa for me? I have the issue right now, we are transitioning from the firestore and everything is based on // edit: Maybe this is the wrong place to ask that topic |
@wiesson I think this issue supabase/postgrest-js#204 is more relevant. |
Oh yes, this is what I was looking for! I just hoped, postgREST could already do this :) |
This is a bit of a pedantic (breaking) issue that I found while writing up the OpenAPI spec: due to the naming convention of Postgres (snake_case), most of the fields in the API are also snake_case. It'd be more idiomatic to use camelCase.
There are also other minor issues that I found (mostly to do with types, e.g.
string
should benumber
), so we can do all that plus the OpenAPI stuff in one go. Probably not gonna eliminate all of such issues, but we can at least kaizen our way there.The text was updated successfully, but these errors were encountered: