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
Batch updating entries with m2m field results in duplicates #15034
Comments
This is technically working as intended, but I agree that the behavior is unexpected and should be considered a bug 👍🏻 |
I'm wondering how we would go ahead and fix that. As to fix it in the api we would have to either introduce a batch mode to relational interfaces or we would have to fix that inside the api. |
@Nitwel We might be able to add a "delete everything" flag next to the create calls for the batch mode in the app side, something like:
|
I don't think that is a solution either as there could be information on the junction table that would get lost in the process. My intuition would be to add ones that dont exist yet and delete the ones, that existed, but are not selected in the batch mode. |
Hmm yeah, though the goal here is to set all items in the batch to the same result, so maybe we'd have to clear out all existing linked junction items after all 🤔 |
We are distributing content (articles, videos, images) to different "services" (customers). So the content collections have a m2m to services collection. During batch you don't know what items have a service assigned already, so "batch-adding" it again leads to duplicates sometimes. Also I see how a A main use case we have is -> launching a new service: So I guess one expectation is to "add", not to overwrite m2ms during batch, but there are many different cases for sure. |
It seems to me that the existing wording and functionality already sets the expectation of batch editing not batch adding. The way to works for other multi-value fields like checkboxes etc is that it completely replaces all values (checked and unchecked ) with the newly specified selections (checked or not checked). Not selecting a relationship in the Bulk Edit is just as meaningful as selecting one. Choosing to Bulk edit relationships and having the system leave existing relationships as-is but adding only newly selected is a bug. It only implements half of the advertised intent of the UI. If the use case exists to "Batch add" (as opposed to "Batch edit"), then that should be accomplished with a new feature or perhaps a Flow or something. |
I agree. The expectation is set that the interface will update every selected item to the same value, rather than modifying the relations on top of what's already there. |
Linear: ENG-210 |
This is a dangerous bug... has it been addressed in v9 or v10? |
Describe the Bug
Batch updating entries which include a many to many field results in duplicates if options are added to it.
To Reproduce
Create a new collection called Items and another collection named Options. Add a new Input field to Options called Name. Create at least 2 new entries in Options with Name set to something unique. Create a new Many to Many field in Items and set Options as the related collection.
Create a few entries in Items and select some Options. You should not be able to add Options you have already selected.
Go to the overview table of Items and select all entries. Open the batch editor and choose one or more Options and hit save. The entries of Items should contain the Options which were added individually and in addition to that all the Options which were selected in the batch editor.
Directus.Bug.Report.Batch.Editing.M2M.mov
Errors Shown
No response
What version of Directus are you using?
9.15.1
What version of Node.js are you using?
Default Directus Docker Image
What database are you using?
Default Directus Docker Image
What browser are you using?
Chrome
How are you deploying Directus?
Docker
The text was updated successfully, but these errors were encountered: