Repository navigation
Conversation
newPivotQuery() only applied wherePivot() and wherePivotIn(), so detach(), sync(), toggle() and updateExistingPivot() ignored wherePivotNull() constraints and touched every pivot row of the parent. Laravel 13 also applies wherePivotBetween() there. Apply both, in Laravel's order. On Laravel 10-12 this narrows those operations when wherePivotNull() is used, matching Laravel itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
Matches the review feedback on Weebly#40: the comments restate what the tests already cover. Rename attachTwoPlain() and second_models_plain() to say what they lack: a custom pivot class. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Applying wherePivotBetween() in pivot queries only matters on Laravel 13, so it moves to Weebly#40 with its tests. This PR keeps the wherePivotNull() fix for Laravel 10-12. The constraint order test needs both loops, so it returns when this branch is rebased onto Weebly#40. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BelongsToMany::newPivotQuery()only appliedwherePivot()andwherePivotIn()constraints. Laravel's ownnewPivotQuery()also applieswherePivotNull(). Because the override skipped it,detach(),sync(),toggle()andupdateExistingPivot()ignoredwherePivotNull()on relations without a custom pivot class. For example,$model->tags()->wherePivotNull('extra')->detach()deleted every pivot row of the parent.Changes
newPivotQuery()appliespivotWhereNullsafter thewherePivotIn()constraints, as Laravel does.Behaviour change on Laravel 10-12
wherePivotNull()now narrowsdetach(),sync(),toggle()andupdateExistingPivot(), as it does in Laravel itself. Code that relied on those calls touching every pivot row will see fewer rows changed.Testing
2 new tests in
PivotTest. Both fail without thesrcchange. They pass locally on PHP 8.3 against SQLite on Laravel 10.50.3, 11.57.0, 12.70.0 and 13.36.0, with no skips.The Laravel 10 and 11 CI legs fail at
composer updateon this branch, as they do onmaster. #40 fixes that.Merging after #40
#40 applies
wherePivotBetween()innewPivotQuery()on Laravel 13. When this branch is rebased onto it:wherePivotNull()loop goes after thewherePivotBetween()loop, which is Laravel's order.Split out of #40, the Laravel 13 support PR, since it changes behaviour on Laravel 10-12.
🤖 Generated with Claude Code