Skip to content

Commit d7ef97d

Browse files
committed
refactor: limit inner hits size and improve id type casting
1 parent 3081776 commit d7ef97d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Query/Grammar.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,9 @@ public function _buildInnerHits($innerQuery)
548548
$innerHits['from'] = $innerQuery->offset;
549549
}
550550
if ($size = $innerQuery->getSetLimit()) {
551-
$innerHits['size'] = $size;
551+
# TODO: David should we handle this diffrently?
552+
# Nested queries have a hard limit of 100 for inner_hits size
553+
$innerHits['size'] = min($size, 100);
552554
}
553555

554556
return $innerHits;

src/Relations/MorphToMany.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public function attach($id, array $attributes = [], $touch = true)
251251
}
252252

253253
// ID Must always be a string val
254-
$id = Arr::wrap((string) $id);
254+
$id = array_map(fn ($item) => (string) $item, Arr::wrap($id));
255255

256256
$query = $this->newRelatedQuery();
257257
$query->whereIn($this->relatedKey, $id);

0 commit comments

Comments
 (0)