From 52c0ea33cc6ceb842363fadeaa9400347eaf3d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Thu, 20 Jul 2023 23:48:26 +0200 Subject: [PATCH] PHPORM-49 Implement `Query\Builder::whereNot` by encapsulating into `$not` (#13) (#15) `Query\Builder::whereNot` was simply ignoring the "not" and breaking the built query. --- CHANGELOG.md | 1 + src/Query/Builder.php | 17 ----------------- tests/Query/BuilderTest.php | 6 ++++++ 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04b823816..d28e9beae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file. - Throw an exception for unsupported `Query\Builder` methods [#9](https://github.com/GromNaN/laravel-mongodb-private/pull/9) by [@GromNaN](https://github.com/GromNaN). - 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). - 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). +- Remove public property `Query\Builder::$paginating` [#15](https://github.com/GromNaN/laravel-mongodb-private/pull/15) by [@GromNaN](https://github.com/GromNaN). ## [3.9.2] - 2022-09-01 diff --git a/src/Query/Builder.php b/src/Query/Builder.php index 4db2b5a91..6321b86de 100644 --- a/src/Query/Builder.php +++ b/src/Query/Builder.php @@ -59,13 +59,6 @@ class Builder extends BaseBuilder */ public $options = []; - /** - * Indicate if we are executing a pagination query. - * - * @var bool - */ - public $paginating = false; - /** * All of the available clause operators. * @@ -574,16 +567,6 @@ public function whereBetween($column, iterable $values, $boolean = 'and', $not = return $this; } - /** - * @inheritdoc - */ - public function forPage($page, $perPage = 15) - { - $this->paginating = true; - - return $this->skip(($page - 1) * $perPage)->take($perPage); - } - /** * @inheritdoc */ diff --git a/tests/Query/BuilderTest.php b/tests/Query/BuilderTest.php index 8c8a00c50..7cd6f0584 100644 --- a/tests/Query/BuilderTest.php +++ b/tests/Query/BuilderTest.php @@ -247,6 +247,12 @@ public static function provideQueryBuilderToMql(): iterable ]), ]; + /** @see DatabaseQueryBuilderTest::testForPage() */ + yield 'forPage' => [ + ['find' => [[], ['limit' => 20, 'skip' => 40]]], + fn (Builder $builder) => $builder->forPage(3, 20), + ]; + /** @see DatabaseQueryBuilderTest::testOrderBys() */ yield 'orderBy multiple columns' => [ ['find' => [[], ['sort' => ['email' => 1, 'age' => -1]]]],