Skip to content

Commit

Permalink
Adapt to doctrine/orm 3
Browse files Browse the repository at this point in the history
- use QueryBuilder::resetDQLPart insead of add( , null)
- adapt composer.json
- did composer update
  • Loading branch information
metaclass-nl committed Jun 25, 2024
1 parent 37b1098 commit 9c66a85
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
},
Expand Down
8 changes: 6 additions & 2 deletions src/Filter/DateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 5 additions & 1 deletion src/Filter/FilterLogic.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9c66a85

Please sign in to comment.