Closed
Description
Describe the Bug
Hello,
I tried to use the unique: true property on a field. It works if a new document is created but not if I try to update a document with the same value of a different document.
Both documents where still in draft mode.
You can use the referenced repo and enable drafts like this
versions: {
drafts: {
validate: true,
},
maxPerDoc: 1,
},
Link to the code that reproduces this issue
https://github.com/tobidemski/payload-uniquefield-errormessage
Reproduction Steps
- use Payload with sqlite
- Create a page document with any value. Example "/" for the page field and save it.
- Create a second document with the same value "/" and try to save. --> Error is shown
- Set the page field value for the second document to "test" and save --> succesful
- Set the page field value for the secon document to "/" and save --> successful
Which area(s) are affected? (Select all that apply)
area: docs
Environment Info
Binaries:
Node: 18.20.8
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant Packages:
payload: 3.39.1
next: 15.3.2
@payloadcms/db-postgres: 3.39.1
@payloadcms/email-nodemailer: 3.39.1
@payloadcms/graphql: 3.39.1
@payloadcms/next/utilities: 3.39.1
@payloadcms/payload-cloud: 3.39.1
@payloadcms/richtext-lexical: 3.39.1
@payloadcms/translations: 3.39.1
@payloadcms/ui/shared: 3.39.1
react: 19.0.0
react-dom: 19.0.0
Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Pro
Available memory (MB): 32510
Available CPU cores: 16
Metadata
Metadata
Assignees
Labels
No labels