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
Unique constraint error can't be extracted in MySQL 5.7 #5719
Comments
@emekatoby Did you create the unique constraint through Directus itself? MySQL doesn't return the affected column when a unique constraint fails, so we can't reliably extract that field name :C Directus tries reading it from the constraint name, but this only works when the constraint was made through Directus directly. |
Thank you for taking the time to submit this! Unfortunately, our team was not been able to reproduce it based on the information provided. Therefore, we will close this ticket for now, but will happily re-open it if new details are provided that allow us to reliably replicate the problem. As a reminder:
This is an automated response. |
I created all fields and unique constraint in directus. When i go to test it in the form section. It shows that error. I did not alter or move anything directly in the MySQL database |
@emekatoby Could you check what the unique index name is in the database directly? You should be able to use: SELECT
CONSTRAINT_NAME,
TABLE_NAME
FROM
information_schema.TABLE_CONSTRAINTS
WHERE
CONSTRAINT_SCHEMA = 'directus' # << USE YOUR DIRECTUS DATABASE HERE
AND CONSTRAINT_TYPE = 'UNIQUE'; |
github.mp4video showing example. I used an entry already present in the DB "1234567890" in the unique field and it threw that same error. I have shut directus down and started it up again, same thing |
Okay. Is there a private way I can send it to you? Plus what do you think the fix would be seeing that you can't reproduce it. Show I do a DB migrate up or down or do an NPM update for my directus instance? |
You can email it directly to me at rijk@directus.io 👍🏻
It's most likely a change in the codebase, so a simple update would be enough |
sent. I am actually using the RC69 release. Which should be the latest. |
Database server |
Ohhhh so you're not on MySQL 8 😄 You're using MySQL 5.7.32. (Directus requires 5.7.8+, so you might run into some issues with JSON fields) I think the db error format has changed between v5 and v8, which means our extraction logic doesn't work for this older version 👍🏻 |
I just confirm it is a problem with MAMP or something. I have a production environment running on the same directus instance I copied into my windows server. I tried the same thing and it echoed the correct validation error. Anyway, while we are here, I wanted to point out another error. The production server I am running has issues loading the logo images. I can see it in the dom, but it doesn't display. I cannot figure out why. |
@supermx1 Your MAMP MySQL version is different from your MySQL version on the production server 👍🏻
Please open a new issue if that's a problem in Directus. It's impossible to track multiple issues in the same "issue" on GitHub 🙂 |
Ok |
Hello everyone, so if I check the field option "Unique - Value has to be unique" and I fill a form to test, and I enter a value that is not unique. It shows the error above, which is not descriptive. The field is not hidden. Secondly, I think it's not standard to display an error at the top of a page for UX reasons, especially for long forms. The user has to scroll to the top to see the errors, instead of highlighting the field(s) that have said errors or validation issues. Adding to it. When a field has validation errors the submit form button (green check button at the top) doesn't give any indication that there are errors on submission. It just stays the same and the user will just be left there clicking and clicking with no action or scroll effect or even warning animation.
Environment
Directus 9.0.0-RC.68
MySQL 8 (MAMP)
NPX
Chrome Version 90.0.4430.212 (Official Build) (x86_64)
The text was updated successfully, but these errors were encountered: