Skip to content

Commit aa58f71

Browse files
committed
Handle empty array in whereIn to return no results
1 parent 44aac1a commit aa58f71

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Query/Builder.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,15 @@ public function whereNotContains(string $field, string $value): static
10631063
*/
10641064
public function whereIn(string $field, array $values): static
10651065
{
1066+
if (empty($values)) {
1067+
// If the array of values is empty, we will
1068+
// add an empty OR filter to the query to
1069+
// ensure that no results are returned.
1070+
$this->rawFilter('(|)');
1071+
1072+
return $this;
1073+
}
1074+
10661075
return $this->orFilter(function (Builder $query) use ($field, $values) {
10671076
foreach ($values as $value) {
10681077
$query->whereEquals($field, $value);

0 commit comments

Comments
 (0)