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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix primary key unique constraint error extraction for MySQL #22434

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

hanneskuettner
Copy link
Contributor

Scope

MySQL does some weird stuff for primary key unique constraints errors, where it doesn't actually tell us the primary key, but instead yells PRIMARY at us. Handle this case in the error extraction logic and propagate that info up the stack to where we actually have the info about the primary key field name.

Additionally MySQL 5.7 won't even tell us the collection we're dealing with, so we have to add that in as well...

What's changed:

  • Added primaryKey flag to the RecordNotUniqueError extensions to propagate error info
  • Fixed handling for unique primary key constraints

Potential Risks / Drawbacks

None

Review Notes / Questions

  • Should this sit this far up the stack, or should we pass more context to the translateDatabaseError function? I'm not sure 馃

Fixes #15033

Copy link

changeset-bot bot commented May 8, 2024

馃 Changeset detected

Latest commit: ce27114

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@directus/api Patch
@directus/errors Patch
directus Patch
@directus/extensions-registry Patch
@directus/memory Patch
@directus/validation Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 馃啎 Needs Triage
Development

Successfully merging this pull request may close these issues.

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