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

[9.x] Skip adding search constraints with empty search on DatabaseEngine #582

Merged
merged 1 commit into from
Feb 8, 2022
Merged

Conversation

rodrigopedra
Copy link
Contributor

@rodrigopedra rodrigopedra commented Feb 8, 2022

Right now if we search for an empty string using the DatabaseEngine, for example in a endpoint that lists all users:

Route::get('/api/users', fn () => User::search(request()->query('q'))->paginate());

Even when the search string is empty, the where clauses are added:

select *
from `users`
where (`users`.`name` like '%%' or `users`.`email` like '%%' or match (`users`.`notes`) against ('' in natural language mode))
order by `id` desc
limit 30 offset 0

This PR skips adding the search where clauses with an empty search string.

@driesvints driesvints changed the title Skip adding search constraints with empty search on DatabaseEngine [9.x] Skip adding search constraints with empty search on DatabaseEngine Feb 8, 2022
@taylorotwell taylorotwell merged commit 3ec268e into laravel:9.x Feb 8, 2022
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.

3 participants