Skip to content

[10.x] Optimize exists validation for empty array input - #48684

Merged
taylorotwell merged 1 commit into
laravel:10.xfrom
mtawil:patch-1
Oct 10, 2023
Merged

[10.x] Optimize exists validation for empty array input#48684
taylorotwell merged 1 commit into
laravel:10.xfrom
mtawil:patch-1

Conversation

@mtawil

@mtawil mtawil commented Oct 10, 2023

Copy link
Copy Markdown
Contributor

This PR addresses a minor efficiency issue in the exists validation method.

Previously, an unnecessary SQL query was executed when validating an empty array:

select count(distinct id) as aggregate from users where 0 = 1

The added check for a zero $expected value now bypasses this query, saving resources while keeping the intended validation behavior.

@mtawil mtawil changed the title optimize exists validation for empty array input [10.x] Optimize exists validation for empty array input Oct 10, 2023
@taylorotwell
taylorotwell merged commit 3b40b36 into laravel:10.x Oct 10, 2023
timacdonald pushed a commit to timacdonald/framework that referenced this pull request Oct 24, 2023
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