Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Update signature of the where(All|Any) methods, make $operator argument required #52384

Conversation

einar-hansen
Copy link
Contributor

This PR proposes to update the signature of the where(All|Any) methods, and potentially the whereNot(All|Any) methods as well. The current implementation has an unintuitive default behavior that may lead to unexpected results.

Current issue:
The $operator argument is optional and defaults to null. This default leads to an unexpected IS NULL condition in the generated SQL when no arguments are provided. Intuitively, one might expect a WHERE EXISTS statement or an equality check (=) if no argument was passed, rather than the current IS NULL behavior.

For example:

$builder->select('*')->from('users')->whereAll(['first_name', 'last_name']);

will generate

SELECT * FROM "users" WHERE ("first_name" IS NULL AND "last_name" IS NULL)

Proposed change:
Modify the method signature to require the $operator argument. This change would align the method behavior with developer expectations and prevent unintended IS NULL conditions.

Note: This PR is currently in draft status pending the resolution of the following related PRs:

Copy link

github-actions bot commented Aug 5, 2024

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant