diff --git a/composer.json b/composer.json index 036140b..8e740f8 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "php": ">=7.2.5", "symfony/http-kernel": "^4.4 || ^5.1 || ^6.0 || ^7.0", "api-platform/core": "^2.7 || ^3.0", - "doctrine/orm": "^2.7" + "doctrine/orm": "^2.14 || ^3.0" }, "require-dev": { }, diff --git a/src/Filter/DateFilter.php b/src/Filter/DateFilter.php index 2f6cee6..13c518e 100644 --- a/src/Filter/DateFilter.php +++ b/src/Filter/DateFilter.php @@ -52,12 +52,16 @@ protected function filterProperty(string $property, $values, QueryBuilder $query } $oldWhere = $queryBuilder->getDQLPart('where'); - $queryBuilder->add('where', null); + $queryBuilder->resetDQLPart('where'); $this->inner->apply($queryBuilder, $queryNameGenerator, $resourceClass, $operation, $contextCopy); $expressions = $queryBuilder->getDQLPart('where')->getParts(); - $queryBuilder->add('where', $oldWhere); + if ($oldWhere === null) { + $queryBuilder->resetDQLPart('where'); + } else { + $queryBuilder->add('where', $oldWhere); //restores old where + } $isNotNull = array_shift($expressions); foreach ($expressions as $expr) { diff --git a/src/Filter/FilterLogic.php b/src/Filter/FilterLogic.php index a5ae611..2535841 100644 --- a/src/Filter/FilterLogic.php +++ b/src/Filter/FilterLogic.php @@ -142,7 +142,11 @@ protected function doGenerate($queryBuilder, $queryNameGenerator, $resourceClass $this->applyFilters($queryBuilder, $queryNameGenerator, $resourceClass, $operation, $subcontext); $newWhere = $queryBuilder->getDQLPart('where'); - $queryBuilder->add('where', $oldWhere); //restores old where + if ($oldWhere === null) { + $queryBuilder->resetDQLPart('where'); + } else { + $queryBuilder->add('where', $oldWhere); //restores old where + } // force $operator logic upon $newWhere $expressions = $this->getAppliedExpressions($newWhere, $marker);