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
wherePivotIn saves the all the params into $this->pivotWheres, which leads to newPivotQuery consider them as normal where clause instead of whereIn clause.
the reason is BelongsToMany::wherePivotIn() saves all the params $this->pivotWheres, as well as BelongsToMany::wherePivot(). when BelongsToMany::newPivotQuery() create new query builder, it will asume everything in $this->pivotWheres is created from wherePivot() and call where() on them.
I've already created a pr to fix this issue, to store and process the params separately.
Activity
themsaid commentedon Jul 21, 2016
How do you use
sync()
withwherePivotIn()
?jhdxr commentedon Jul 21, 2016
Here's the example
assume the primary key of lesson is 1, and 2 for current user, then the correct sql should be
however, laravel generate following sql now:
the reason is
BelongsToMany::wherePivotIn()
saves all the params$this->pivotWheres
, as well asBelongsToMany::wherePivot()
. whenBelongsToMany::newPivotQuery()
create new query builder, it will asume everything in$this->pivotWheres
is created fromwherePivot()
and callwhere()
on them.I've already created a pr to fix this issue, to store and process the params separately.
GrahamCampbell commentedon Jul 21, 2016
Closing to move discussion to the PR.