You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Normally the db-postgres adapter translates the camel-cased name to snake-case e.g. phoneNumber becomes phone_number in the Postgres table.
However, when the field is nested within a group the convention is suddenly ignored and you end up with something like info_phoneNumber instead of info_phone_number. This is unexpected to me as I'm still using the exact same field configuration but moving it inside of a group, so the two following a different convention for the same property seems odd.
I want to maintain consistent naming conventions in the db so I used snake-case in the field config name (phone_number), but that leaves in inconsistent with the conventions used for everything else.
Additionally I tried using the dbName property on the field to workaround this while keeping the same convention for name but that seems to have no effect, the resulting property name is still info_phoneNumber.
{name: 'info',type: 'group',fields: [{name: 'phoneNumber',dbName: 'phone_number'/* <- Does nothing */}]}
Reproduction Steps
Setup Payload project with db-postgres
Create a collection with a group and a nested field with camel-cased name
Note the difference in convention of the resulting db property name
Attempt to override with dbName prop to fix.
Note dbName doesn't work.
Adapters and Plugins
No response
The text was updated successfully, but these errors were encountered:
Link to reproduction
No response
Payload Version
3.0.0
Node Version
18
Next.js Version
15
Describe the Bug
I have a collection with a group
info
and a set of nested fields.I named these fields following the camelcase convention used throughout the Payload docs:
Normally the
db-postgres
adapter translates the camel-cased name to snake-case e.g.phoneNumber
becomesphone_number
in the Postgres table.However, when the field is nested within a group the convention is suddenly ignored and you end up with something like
info_phoneNumber
instead ofinfo_phone_number
. This is unexpected to me as I'm still using the exact same field configuration but moving it inside of a group, so the two following a different convention for the same property seems odd.I want to maintain consistent naming conventions in the db so I used snake-case in the field config name (
phone_number
), but that leaves in inconsistent with the conventions used for everything else.Additionally I tried using the
dbName
property on the field to workaround this while keeping the same convention forname
but that seems to have no effect, the resulting property name is stillinfo_phoneNumber
.Reproduction Steps
db-postgres
dbName
prop to fix.dbName
doesn't work.Adapters and Plugins
No response
The text was updated successfully, but these errors were encountered: