Skip to content

Postgres dbName on deep array field regression #12136

Closed
@Rymar

Description

@Rymar

Describe the Bug

After upgrading version from 3.33.0 to 3.34.0 deeply nested array fields stopped working. Error happens on Postgres, haven't checked other databases.

import type { GlobalConfig } from 'payload';

export const Header: GlobalConfig = {
  slug: 'header',
  fields: [
    {
      name: 'itemsLvl1',
      type: 'array',
      dbName: 'header_items_lvl1',
      fields: [
        {
          name: 'label',
          type: 'text',
        },
        {
          name: 'itemsLvl2',
          type: 'array',
          dbName: 'header_items_lvl2',
          fields: [
            {
              name: 'label',
              type: 'text',
            },
            {
              name: 'itemsLvl3',
              type: 'array',
              dbName: 'header_items_lvl3',
              fields: [
                {
                  name: 'label',
                  type: 'text',
                },
                {
                  name: 'itemsLvl4',
                  type: 'array',
                  dbName: 'header_items_lvl4',
                  fields: [
                    {
                      name: 'label',
                      type: 'text',
                    },
                  ],
                },
              ],
            },
          ],
        },
      ],
    },
  ],
}

Error:

error: table name "header__header_items_lvl1__header_items_lvl2__header_items_lvl3" specified more than once

When i change version to 3.33.0 or i remove 2 last levels it starts to work again.

Might be related to #11995.

Link to the code that reproduces this issue

https://github.com/Rymar/payload-deep-dbname

Reproduction Steps

Open home page from linked repo. It makes

await payload.findGlobal({
  slug: "header",
});

result
Image

Which area(s) are affected? (Select all that apply)

db-postgres

Environment Info

Payload 3.34.0
Next 15.3.0
Postgres database

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions