-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Query Failure using Many to Many when saving an item #2013
Comments
I am facing the same issue when trying to add multiple files. Running version 6.4.2 from https://github.com/directus/directus-docker. Happy to provide full bug report if necessary. Logs are pretty much identical to the ones above:
|
Hey @cjstage, @Nicolaidavies thanks for the report/logs, would it be possible to share the schema (mysql dump) of the database you are using, in order to us replicate this issue? |
@wellingguzman please find a dump here: https://www.dropbox.com/s/9hvp7ha4647d9i6/backup.sql?dl=1 |
I had a similar issue and it turned out that there wasn't a default value set for the 'sort' property which caused the insert query to fail. Maybe that's the case? Best thing to be 100% sure, is to copy the query in question and try to run it manually in MySQL. |
Thanks @Nicolaidavies. I will give it a shot later today. @iKonrad it likely to be that as well, but the logs are different in this case, or can be both. Ref to |
@wellingguzman I just noticed that I sent you the wrong mysql dump. I removed the row giving me issues from the table and took a mysql dump of that. Not particularly useful when trying to figure out what's wrong. Please find the mysql dump with the issue here: https://www.dropbox.com/s/6uclxutfv1mmb7z/backup.sql?dl=1 I apologize for the inconvenience. I hope I didn't waste your time. Let me also elaborate a bit on the issue: Other than not being able to create a new row with a type of multiple files, I am also not able to view other rows that were created without the multi files type. I also noticed that the logs I posted earlier were incomplete. Please find the full logs here:
Thanks for the help! |
I just ran into the exact same issue which was solved by adding a default value to the sort on the junction table, as suggested by @iKonrad |
@jjbandit & @iKonrad thank you for the suggestion. Where exactly do I need to add a sort value? Is it on the table I created ( How do I add a default value to the sort? Is it through the directus UI or do I have to run some SQL? |
Just to clarify, I am not joining any custom tables I created. I just want to add a 'multiple files' column to a table I created. In other words there is nothing custom, Ideally this should work out of the box as it is functionality provided by directus. Please see a screen recording here: https://www.dropbox.com/s/4n1i73184s0c7sw/Directus_errors.mov?dl=0 As you can see from the video, I am able to save before adding this new column. But as soon as I add the multiple files column I am unable to save. |
Hey @Nicolaidavies, when you create the multiple files column, you didn't create the correct relationship, and make directus activity as your junction table. Read how to the m2m (or any other relationships) works on Directus, here: https://medium.com/directus/understanding-relationships-it-isnt-complicated-35e0dcf78450 |
@Nicolaidavies You need to create a This new table, let's call it |
@jjbandit Thank you for your answer. I got it working. @wellingguzman Thank you for the continued help. I was under the impression that the default values that were filled in after selecting "Multiple files" would create the correct relationship. Since I got it working I'm just curious at this point: how would one setup the relationship with Once again, thanks for creating directus, it's saved me several hours if not days of work! |
When you choose multiple files it automatically pick Let us know if this works for you. As this is a configuration issue and not an actual bug I will close this ticket. Note: the next version will include a default value (nullable) for |
For security issues, please email support@getdirectus.com directly.
To help us resolve your issue more quickly, please use the following template:
For feature requests/voting please use the Directus Request Tool, or come chat with us through getdirectus.com. Accepted feature requests will be added to GitHub Issues for assignment.
Version Info
Expected Behavior
Create a Many to Many relationship, save item successfully.
Actual Behavior
Throws query error: This query failed: INSERT INTO
web_placements
(name
,url
) VALUES ('face', 'face') in...Steps to Reproduce
Schema Dump, Logs, or Screenshots
The text was updated successfully, but these errors were encountered: