[12.x] Fix orWhere() with array syntax to join conditions with AND #57511
+15
−15
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.
Issue: #53628 - orWhere() with array syntax was generating OR between array items instead of AND.
The Bug
->where('status', 'Queued')
->orWhere([
['status', '=', 'On Water'],
['checkout_date', '!=', '']
])
Was generating (WRONG):
WHERE status = ? OR (status = ? OR checkout_date != ?)
Now generates (CORRECT):
WHERE status = ? OR (status = ? AND checkout_date != ?)
🔧 The Fix
Modified Builder.php:928-939 to remove the $boolean parameter from individual array items. Now the $boolean only controls how the group connects to previous clauses, not how items inside the array are joined.
This pull request updates the handling of array-based conditions in the query builder, specifically changing how multiple conditions within an array are combined. Previously, these conditions were joined using the
ORoperator, but now they are joined using theANDoperator. This affects both the query generation logic and the associated tests to ensure consistent results.