Skip to content

[11.x] use exists() instead of count()#53328

Merged
taylorotwell merged 2 commits intolaravel:11.xfrom
browner12:AB-exist-assertions
Oct 29, 2024
Merged

[11.x] use exists() instead of count()#53328
taylorotwell merged 2 commits intolaravel:11.xfrom
browner12:AB-exist-assertions

Conversation

@browner12
Copy link
Contributor

we only need to check for existence of a record here, not for the actual count, and exists() is generally more performant than a count.

we only need to check for existence of a record here, not for the actual count, and `exists()` is generally more performant than a count.
- add an "exists" assertions, and update `mockCountBuilder()` to accept this first, and adjust all the calls to it.
- I thought about renaming `mockCountBuilder()` to `mockBuilder()`, which would probably be a little clearer now, but I wanted to keep this easy to review. if this is accepted, I'd probably go back and make that semantic change separately.
@taylorotwell taylorotwell merged commit 36b6991 into laravel:11.x Oct 29, 2024
@browner12 browner12 deleted the AB-exist-assertions branch March 17, 2025 16:29
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.

2 participants