Skip to content

Commit 9f5e849

Browse files
committed
#1930 assert that a instance of the Mongo query builder is used
The base `update(..)` method and the MongoDB `update(..)` differ in the amount of arguments. Adding a assertion to make sure the correct one is used.
1 parent 36e6768 commit 9f5e849

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Eloquent/Builder.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
99
use MongoDB\Driver\Cursor;
1010
use MongoDB\Laravel\Helpers\QueriesRelationships;
11+
use MongoDB\Laravel\Query\Builder as MongoDBQueryBuilder;
1112
use MongoDB\Model\BSONDocument;
1213

1314
use function array_key_exists;
1415
use function array_merge;
16+
use function assert;
1517
use function collect;
1618
use function is_array;
1719
use function iterator_to_array;
@@ -71,7 +73,10 @@ public function update(array $values, array $options = [])
7173
return 1;
7274
}
7375

74-
return $this->toBase()->update($this->addUpdatedAtColumn($values), $options);
76+
$builder = $this->toBase();
77+
assert($builder instanceof MongoDBQueryBuilder);
78+
79+
return $builder->update($this->addUpdatedAtColumn($values), $options);
7580
}
7681

7782
/** @inheritdoc */

0 commit comments

Comments
 (0)