Skip to content

Commit 632fdff

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 99b5fcf commit 632fdff

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;
@@ -62,7 +64,10 @@ public function update(array $values, array $options = [])
6264
return 1;
6365
}
6466

65-
return $this->toBase()->update($this->addUpdatedAtColumn($values), $options);
67+
$builder = $this->toBase();
68+
assert($builder instanceof MongoDBQueryBuilder);
69+
70+
return $builder->update($this->addUpdatedAtColumn($values), $options);
6671
}
6772

6873
/** @inheritdoc */

0 commit comments

Comments
 (0)