[13.x] feat: add orWhereKey and orWhereKeyNot to Eloquent Builder - #61154
Merged
Conversation
Consolidate whereKey and whereKeyNot into a single method with $boolean and $not parameters, following the same pattern used by whereIn/orWhereIn/whereNotIn/orWhereNotIn on the base query builder. whereKeyNot now delegates to whereKey with $not=true, eliminating the duplicated key-type checking and array-handling logic. Add orWhereKey and orWhereKeyNot methods to allow OR-combined primary key constraints without restructuring queries.
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.
Hello!
There's been many, many times where I've wanted to reach for a
orWhereKey()method, but it doesn't exist so I've had to completely restructure my query or fallback to the->orWhereIn('id', ...)that thewhereKey()method was generally supposed to replace.This PR adds both the
orWhereKey()andorWhereKeyNot()methods for completeness. The existingwhereKey()/whereKeyNot()methods were basically duplicates of each other with a lot of repetitive code, so that's been cleaned up as well.Note
This is not a BC from the caller's perspective, however, this does change the method signatures so I guess this technically would be a BC if someone extended the Builder class and overrode the
whereKey/whereKeyNotmethods (but not sure why anyone would do that).In any case, let me know if it's acceptable to put into 13.x, or if I need to target 14.x
Thanks!