Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4285880

Browse files
committed
Validate arg type and avoid subsequent error
1 parent 2cf1828 commit 4285880

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

‎src/Eloquent/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ public function eagerLoadRelations(array $models)
364364
->where($withAggregate['constraints'])
365365
->whereIn($withAggregate['relation']->getForeignKeyName(), $modelIds)
366366
->groupBy($withAggregate['relation']->getForeignKeyName())
367-
->aggregate($withAggregate['function'], [$withAggregate['column'] ?? $withAggregate['relation']->getPrimaryKeyName()]);
367+
->aggregate($withAggregate['function'], [$withAggregate['column']]);
368368

369369
foreach ($models as $model) {
370370
$value = $withAggregate['function'] === 'count' ? 0 : null;

‎src/Query/Builder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public function toMql(): array
346346
if ($this->aggregate) {
347347
$function = $this->aggregate['function'];
348348

349-
foreach ((array) $this->aggregate['columns'] as $column) {
349+
foreach ($this->aggregate['columns'] as $column) {
350350
// Add unwind if a subdocument array should be aggregated
351351
// column: subarray.price => {$unwind: '$subarray'}
352352
$splitColumns = explode('.*.', $column);
@@ -355,7 +355,7 @@ public function toMql(): array
355355
$column = implode('.', $splitColumns);
356356
}
357357

358-
$aggregations = blank($this->aggregate['columns']) ? [] : (array) $this->aggregate['columns'];
358+
$aggregations = blank($this->aggregate['columns']) ? [] : $this->aggregate['columns'];
359359

360360
if (in_array('*', $aggregations) && $function === 'count' && empty($group['_id'])) {
361361
$options = $this->inheritConnectionOptions($this->options);
@@ -506,11 +506,11 @@ public function getFresh($columns = [], $returnLazy = false)
506506
// here to either the passed columns, or the standard default of retrieving
507507
// all of the columns on the table using the "wildcard" column character.
508508
if ($this->columns === null) {
509-
$this->columns = (array) $columns;
509+
$this->columns = $columns;
510510
}
511511

512512
// Drop all columns if * is present, MongoDB does not work this way.
513-
if (in_array('*', (array) $this->columns)) {
513+
if (in_array('*', $this->columns)) {
514514
$this->columns = [];
515515
}
516516

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /