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 4514964

Browse files
GromNaNalcaeus
authored andcommitted
PHPORM-50 PHPORM-65 Remove call to deprecated Collection::count for countDocuments (#18)
https://www.mongodb.com/docs/php-library/current/reference/method/MongoDBCollection-count/ Fix pass options to countDocuments for transaction session
1 parent e045fab commit 4514964

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
1111
- Throw an exception when `Query\Builder::orderBy()` is used with invalid direction [#7](https://github.com/GromNaN/laravel-mongodb-private/pull/7) by [@GromNaN](https://github.com/GromNaN).
1212
- Throw an exception when `Query\Builder::push()` is used incorrectly [#5](https://github.com/GromNaN/laravel-mongodb-private/pull/5) by [@GromNaN](https://github.com/GromNaN).
1313
- Remove public property `Query\Builder::$paginating` [#15](https://github.com/GromNaN/laravel-mongodb-private/pull/15) by [@GromNaN](https://github.com/GromNaN).
14+
- Remove call to deprecated `Collection::count` for `countDocuments` [#18](https://github.com/GromNaN/laravel-mongodb-private/pull/18) by [@GromNaN](https://github.com/GromNaN).
1415

1516
## [3.9.2] - 2022年09月01日
1617

‎src/Query/Builder.php‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,9 @@ public function toMql(): array
266266
$aggregations = blank($this->aggregate['columns']) ? [] : $this->aggregate['columns'];
267267

268268
if (in_array('*', $aggregations) && $function == 'count') {
269-
return ['count' => [$wheres, []]];
269+
$options = $this->inheritConnectionOptions();
270+
271+
return ['countDocuments' => [$wheres, $options]];
270272
} elseif ($function == 'count') {
271273
// Translate count into sum.
272274
$group['aggregate'] = ['$sum' => 1];
@@ -329,7 +331,7 @@ public function toMql(): array
329331

330332
$options = $this->inheritConnectionOptions();
331333

332-
return ['distinct' => [$column, $wheres ?: [], $options]];
334+
return ['distinct' => [$column, $wheres, $options]];
333335
} // Normal query
334336
else {
335337
// Convert select columns to simple projections.
@@ -396,7 +398,7 @@ public function getFresh($columns = [], $returnLazy = false)
396398
$this->columns = [];
397399
}
398400

399-
$command = $this->toMql($columns);
401+
$command = $this->toMql();
400402
assert(count($command) >= 1, 'At least one method call is required to execute a query');
401403

402404
$result = $this->collection;

0 commit comments

Comments
(0)

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