You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've encountered an issue with Directus service layer when attempting to update relations by deleting items. Specifically, while updating relations with a payload that includes item deletion, only the first 100 related items are being deleted due to default limit constraints.
The behavior is observed in Directus version 10.10.3.
The issue seems to be with how limits are handled or not handled when updating relations, specifically for deletion operations. For creation operations, similar logic using a deep update with a _limit: -1 works as expected and allows creating more than 100 relation items.
It would be beneficial to have consistent handling of limits for both creation and deletion of relation items to ensure full flexibility in managing relations through the Directus services layer.
To Reproduce
Create a relation between two collections that can have more than 100 related items.
Try to update a relation by deleting more than 100 items at once using the updateOne method in the ItemsService.
Expected Behavior
All specified related items should be deleted from the relation, regardless of the number exceeding the default limit.
Actual Behavior
Only the first 100 related items are being deleted when the relation is updated. This seems to be a limitation not present during the creation of relations.
Example code
// Assuming promotionService is an instance of ItemsService configured for a 'promotions' collectionawaitpromotionService.updateOne(promotionId,{related_items: {// Assuming 'related_items' is the field representing the relationdelete: arrayOfItemIdsExceeding100// An array of more than 100 item IDs to be deleted from the relation}},{deep: {related_items: {_limit: -1// Attempting to bypass the default limit (does not work as expected)}}});
Directus Version
v10.10.3
Hosting Strategy
Self-Hosted (Custom)
The text was updated successfully, but these errors were encountered:
Looking at the API of the ItemService neither the updateMany/updateOne nor the createMany/createOne offer the query parameter with the deep property you are trying to use. So the additional parameters you're passing are getting ignored.
The reason the create/update operation is working is that it is sequentially processing each related item one at a time, setting the foreign key to the parent item. Since this is a sequential operations we don't run into any query limit as at most one item is processed at the time.
The reason the delete isn't working is that instead of sequentially updating each item and setting its foreign key to null we do a bulk update/delete for all objects matching the keys you are trying to delete, which gets limited by the default query limit. As a workaround, until we decide if we want / can support overriding the limit in such cases, you can manually run a nullify operation as:
Describe the Bug
I've encountered an issue with Directus service layer when attempting to update relations by deleting items. Specifically, while updating relations with a payload that includes item deletion, only the first 100 related items are being deleted due to default limit constraints.
The behavior is observed in Directus version 10.10.3.
The issue seems to be with how limits are handled or not handled when updating relations, specifically for deletion operations. For creation operations, similar logic using a deep update with a _limit: -1 works as expected and allows creating more than 100 relation items.
It would be beneficial to have consistent handling of limits for both creation and deletion of relation items to ensure full flexibility in managing relations through the Directus services layer.
To Reproduce
Expected Behavior
All specified related items should be deleted from the relation, regardless of the number exceeding the default limit.
Actual Behavior
Only the first 100 related items are being deleted when the relation is updated. This seems to be a limitation not present during the creation of relations.
Example code
Directus Version
v10.10.3
Hosting Strategy
Self-Hosted (Custom)
The text was updated successfully, but these errors were encountered: