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

New item with manually entered string primary key does not show "Field has to be unique" error message #15033

Open
koksikus opened this issue Aug 11, 2022 · 4 comments · May be fixed by #22434

Comments

@koksikus
Copy link

Describe the Bug

When I create a new collection with the primary key field and select "manually entered string", it does not show a duplication message when I enter the same number - it does not allow only to save. I can not select the uniqueness field because a database error pops up.

To Reproduce

Data-Model.mp4

Errors Shown

No response

What version of Directus are you using?

9.15.1

What version of Node.js are you using?

16.14.1

What database are you using?

MySQL

What browser are you using?

Edge

How are you deploying Directus?

locally

@licitdev
Copy link
Member

This issue applies when a conflicting manual primary key is sent.

The RecordNotUniqueException for fields contain the field when the unique constraint is triggered.

image

However when it's for the primary key, the field is null.

image

if (field) {
super(`Field "${field}" has to be unique.`, 400, 'RECORD_NOT_UNIQUE', extensions);
} else {
super(`Field has to be unique.`, 400, 'RECORD_NOT_UNIQUE', extensions);
}

@rijkvanzanten
Copy link
Member

Some database errors don't always return the field that was the one conflicting (very annoying). The app should show some sort of fallback warning for those (even though it's not as helpful).

@azrikahar
Copy link
Contributor

Ref #15063 (comment) for additional context on a similar situation but with composite unique constraint.

@azrikahar azrikahar changed the title New collection with manually entered string does not show duplication message New item with manually entered string primary key does not show "Field has to be unique" error message Aug 17, 2022
@rijkvanzanten
Copy link
Member

Linear: ENG-211

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📋 Backlog
Development

Successfully merging a pull request may close this issue.

4 participants