syncWithoutDetaching is throwing an integrity constraint violation, allows unlisted arguments #49835
Unanswered
drewgallagher
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
We are using
syncWithoutDetaching
with a table called strategy_department which has a unique constraint on a primary key with strategy_id and department_id having to be unique.Laravel allows us to pass a single arg like an id (i.e. 1001), however the docs don't list that as an option https://laravel.com/api/8.x/Illuminate/Database/Eloquent/Relations/BelongsToMany.html#method_syncWithoutDetaching. There are no errors thrown.
However we see an on and off integrity constraint when using it this way. Is there an error with syncWithDetaching with a single id passed as an arg that doesn't allows work?
Sample code
$strategy_package->strategy()->first()->departments()->syncWithoutDetaching($task->service->department->id);
We are triggering a graphql endpoint with this code with several different requests (that could have the same department id).
Is there an issue running this call in parallel?
$strategy_package->strategy()->first()->departments()->sync($task->service->department->id, false);
appears to be working correctly, not sure why one would produce a result that the other would not
We are using V8 of Laravel
Beta Was this translation helpful? Give feedback.
All reactions