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

Fields in groups ignore typical table naming convention (postgres) #6955

Open
tomparkp opened this issue Jun 27, 2024 · 0 comments
Open

Fields in groups ignore typical table naming convention (postgres) #6955

tomparkp opened this issue Jun 27, 2024 · 0 comments
Labels
status: needs-triage Possible bug which hasn't been reproduced yet v3

Comments

@tomparkp
Copy link

tomparkp commented Jun 27, 2024

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:

{
  name: 'info',
  type: 'group',
  fields: [{ name: 'phoneNumber', ...}]
}

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

  1. Setup Payload project with db-postgres
  2. Create a collection with a group and a nested field with camel-cased name
  3. Note the difference in convention of the resulting db property name
  4. Attempt to override with dbName prop to fix.
  5. Note dbName doesn't work.

Adapters and Plugins

No response

@tomparkp tomparkp added status: needs-triage Possible bug which hasn't been reproduced yet v3 labels Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs-triage Possible bug which hasn't been reproduced yet v3
Projects
None yet
Development

No branches or pull requests

1 participant