Skip to content

Commit

Permalink
Fix Mongo form filters
Browse files Browse the repository at this point in the history
  • Loading branch information
alterphp committed Jul 22, 2021
1 parent 3039fe3 commit e2f2968
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/EventListener/MongoOdmPostQueryBuilderSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,33 +59,33 @@ protected function filterQueryBuilder(QueryBuilder $queryBuilder, string $field,
switch ($operator) {
case ListFilter::OPERATOR_EQUALS:
if ('_NULL' === $value) {
$filterExpr = $queryBuilder->expr()->field($field)->equals(null);
$filterExpr = $queryBuilder->expr()->field($queryField)->equals(null);
} elseif ('_NOT_NULL' === $value) {
$filterExpr = $queryBuilder->expr()->field($field)->notEqual(null);
$filterExpr = $queryBuilder->expr()->field($queryField)->notEqual(null);
} else {
$filterExpr = $queryBuilder->expr()->field($field)->equals($value);
$filterExpr = $queryBuilder->expr()->field($queryField)->equals($value);
}
break;
case ListFilter::OPERATOR_NOT:
$filterExpr = $queryBuilder->expr()->field($field)->not($value);
$filterExpr = $queryBuilder->expr()->field($queryField)->not($value);
break;
case ListFilter::OPERATOR_IN:
// Checks that $value is not an empty Traversable
if (0 < \count($value)) {
$filterExpr = $queryBuilder->expr()->field($field)->in($value);
$filterExpr = $queryBuilder->expr()->field($queryField)->in($value);
}
break;
case ListFilter::OPERATOR_GT:
$filterExpr = $queryBuilder->expr()->field($field)->gt($value);
$filterExpr = $queryBuilder->expr()->field($queryField)->gt($value);
break;
case ListFilter::OPERATOR_GTE:
$filterExpr = $queryBuilder->expr()->field($field)->gte($value);
$filterExpr = $queryBuilder->expr()->field($queryField)->gte($value);
break;
case ListFilter::OPERATOR_LT:
$filterExpr = $queryBuilder->expr()->field($field)->lt($value);
$filterExpr = $queryBuilder->expr()->field($queryField)->lt($value);
break;
case ListFilter::OPERATOR_LTE:
$filterExpr = $queryBuilder->expr()->field($field)->lte($value);
$filterExpr = $queryBuilder->expr()->field($queryField)->lte($value);
break;

case ListFilter::OPERATOR_NOTIN:
Expand Down

0 comments on commit e2f2968

Please sign in to comment.