From cf3695a888fd2250e5f2fa5615c365803dc895f3 Mon Sep 17 00:00:00 2001 From: Sebastian Meyer Date: Fri, 12 Jan 2024 08:09:26 +0100 Subject: [PATCH] Allow hierarchical sets --- src/Database.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Database.php b/src/Database.php index 9729659..b2b2e26 100644 --- a/src/Database.php +++ b/src/Database.php @@ -32,6 +32,7 @@ use Doctrine\ORM\Configuration as DoctrineConfiguration; use Doctrine\ORM\EntityManager; use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\Proxy\ProxyFactory; +use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\Tools\Pagination\Paginator; use OCC\Basics\Traits\Singleton; use OCC\OaiPmh2\Entity\Format; @@ -313,8 +314,17 @@ class Database $until = $until->format('Y-m-d\TH:i:s\Z'); } if (isset($set)) { - $dql->andWhere($dql->expr()->in('record.sets', ':set')); - $dql->setParameter('set', $set); + $dql->innerJoin( + Set::class, + 'sets', + Join::WITH, + $dql->expr()->orX( + $dql->expr()->eq('sets.spec', ':setSpec'), + $dql->expr()->like('sets.spec', ':setLike') + ) + ); + $dql->setParameter('setSpec', $set->getSpec()); + $dql->setParameter('setLike', $set->getSpec() . ':%'); $set = $set->getSpec(); } $query = $dql->getQuery();