-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed
Labels
Description
Link to reproduction
No response
Environment Info
Binaries:
Node: 18.20.2
npm: 10.5.0
Yarn: N/A
pnpm: 9.1.0
Relevant Packages:
payload: 3.0.0-beta.97
next: 15.0.0-canary.104
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.5.0: Wed May 1 20:13:18 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6030
Available memory (MB): 36864
Available CPU cores: 12
Describe the Bug
Postgres column names for select fields are not converted to snake case, unlike all other fields.
For example, an input field with the name fooBar will result in a pg column name of foo_bar.
However, a select field named fooBar will create a column called fooBar.
The offending logic may be here, where the fieldName argument should instead be columnName:
| targetTable[fieldName] = withDefault(adapter.enums[enumName](fieldName), field) |
Reproduction Steps
- Configure the Postgres db adapter
- Create a collection (e.g. Foo)
- Create an input field with a camelCase name (e.g.
fooInput) - Create a select field with a camelCase name (e.g.
fooSelect) - Run
payload migrate:create - Open the migration output file.
Expected output:
CREATE TABLE IF NOT EXISTS "foos" (
"foo_input" varchar,
"foo_select" "enum_foos_foo_select",
);Actual output:
CREATE TABLE IF NOT EXISTS "foos" (
"foo_input" varchar,
"fooSelect" "enum_foos_foo_select",
);Adapters and Plugins
db-postgres
thekiwi