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

Duplicate index error with similar field names #8752

Closed
ars3nicum opened this issue Oct 16, 2024 · 3 comments · Fixed by #8754
Closed

Duplicate index error with similar field names #8752

ars3nicum opened this issue Oct 16, 2024 · 3 comments · Fixed by #8754

Comments

@ars3nicum
Copy link

Describe the Bug

Collection with the following fields:

{
      name: 'blocks',
      type: 'array',
      localized: true,
      label: 'Blocks',
      fields: [
        
        {
          name: 'image',
          type: 'upload',
          relationTo: 'media',
          localized: true,
        },
      ],
    },
    
    {
      name: 'blocksImage',
      type: 'upload',
      relationTo: 'media',
    }

will cause an error
Warning We've found duplicated index name across public schema. Please rename your index in either the ... table or the table with the duplicated index name

because of similarity of names blocks.image and blocksImage

Link to the code that reproduces this issue

https://github.com/ars3nicum/payload-bug

Reproduction Steps

written above

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

db-postgres

Environment Info

Payload: beta 114
Node.js: 22.9.0
Next.js: 15.0.0-canary.173

@ars3nicum ars3nicum added status: needs-triage Possible bug which hasn't been reproduced yet v3 labels Oct 16, 2024
@ars3nicum ars3nicum changed the title Duplicate index error with some similar fieldnames Duplicate index error with similar field names Oct 16, 2024
@r1tsuu r1tsuu linked a pull request Oct 16, 2024 that will close this issue
DanRibbens added a commit that referenced this issue Oct 17, 2024
Fixes #8752

Previously, trying to define a config like this:
```ts
{
  type: 'text',
  name: 'someText',
  index: true,
},
{
  type: 'array',
  name: 'some',
  index: true,
  fields: [
    {
      type: 'text',
      name: 'text',
      index: true,
    },
  ],
}
```

Lead to the error:
```
Warning  We've found duplicated index name across public schema. Please rename your index in either the demonstration table or the table with the duplicated index name
```

Now, if we encounter duplicates, we increment the name like this:
`collection_some_text_idx`
`collection_some_text_1_idx`

---------

Co-authored-by: Dan Ribbens <[email protected]>
@r1tsuu
Copy link
Member

r1tsuu commented Oct 17, 2024

Fixed in #8754

@r1tsuu r1tsuu closed this as completed Oct 17, 2024
@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Oct 17, 2024
Copy link
Contributor

🚀 This is included in version v3.0.0-beta.116

Copy link
Contributor

This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants