Skip to content

Commit

Permalink
Fix filters
Browse files Browse the repository at this point in the history
  • Loading branch information
rjzondervan committed Aug 14, 2024
1 parent 2278a80 commit 7de8d27
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Db/PublicationMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use OCP\AppFramework\Db\Entity;
use OCP\AppFramework\Db\QBMapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\DB\Types;
use OCP\IDBConnection;

class PublicationMapper extends QBMapper
Expand All @@ -30,6 +31,9 @@ public function find(int $id): Publication

private function parseComplexFilter(IQueryBuilder $queryBuilder, array $filter, string $name): IQueryBuilder
{
var_dump($filter);


foreach($filter as $key => $value) {
switch($key) {
case '>=':
Expand All @@ -49,7 +53,7 @@ private function parseComplexFilter(IQueryBuilder $queryBuilder, array $filter,
$queryBuilder->andWhere($queryBuilder->expr()->lt($name, $queryBuilder->createNamedParameter($value)));
break;
default:
$queryBuilder->andWhere($queryBuilder->expr()->eq($name, $queryBuilder->createNamedParameter($filter)));
$queryBuilder->andWhere($queryBuilder->expr()->eq(x: $name, y: $queryBuilder->createNamedParameter($filter)));
}
}

Expand All @@ -60,7 +64,7 @@ private function addFilters(IQueryBuilder $queryBuilder, array $filters): IQuery
{
foreach($filters as $key => $filter) {
if(is_array($filter) === false) {
$queryBuilder->andWhere($queryBuilder->expr()->eq($key, $queryBuilder->createNamedParameter($key)));
$queryBuilder->andWhere($queryBuilder->expr()->eq($key, $queryBuilder->createNamedParameter($filter)));
$queryBuilder->setParameter($key, $filter);
continue;
}
Expand Down

0 comments on commit 7de8d27

Please sign in to comment.