[person][export] Fixed: rename the alias for accompanying_period to acp in filter associated with person

This commit is contained in:
Julien Fastré 2022-09-20 17:02:35 +02:00
parent 35a2d08267
commit 59b22dbb6d
5 changed files with 19 additions and 16 deletions

View File

@ -11,6 +11,7 @@ and this project adheres to
## Unreleased ## Unreleased
<!-- write down unreleased development here --> <!-- write down unreleased development here -->
* [person][export] Fixed: rename the alias for `accompanying_period` to `acp` in filter associated with person
## Test releases ## Test releases

View File

@ -25,13 +25,17 @@ class AbstractAccompanyingPeriodExportElement
*/ */
protected function addJoinAccompanyingPeriod(QueryBuilder $query): void protected function addJoinAccompanyingPeriod(QueryBuilder $query): void
{ {
if (false === $this->havingAccompanyingPeriodInJoin($query)) {
if (false === in_array('person', $query->getAllAliases(), true)) { if (false === in_array('person', $query->getAllAliases(), true)) {
throw new LogicException("the alias 'person' does not exists in " throw new LogicException("the alias 'person' does not exists in "
. 'query builder'); . 'query builder');
} }
$query->join('person.accompanyingPeriods', 'accompanying_period'); if (!in_array('acppart', $query->getAllAliases(), true)) {
$query->join('person.accompanyingPeriodParticipations', 'acppart');
}
if (!in_array('acp', $query->getAllAliases(), true)) {
$query->join('acppart.accompanyingPeriod', 'acp');
} }
} }
@ -40,8 +44,6 @@ class AbstractAccompanyingPeriodExportElement
*/ */
protected function havingAccompanyingPeriodInJoin(QueryBuilder $query): bool protected function havingAccompanyingPeriodInJoin(QueryBuilder $query): bool
{ {
$joins = $query->getDQLPart('join') ?? []; return in_array('acp', $query->getAllAliases(), true);
return in_array('accompanying_period', $query->getAllAliases(), true);
} }
} }

View File

@ -32,8 +32,8 @@ class AccompanyingPeriodClosingFilter extends AbstractAccompanyingPeriodExportEl
$this->addJoinAccompanyingPeriod($qb); $this->addJoinAccompanyingPeriod($qb);
$clause = $qb->expr()->andX( $clause = $qb->expr()->andX(
$qb->expr()->lte('accompanying_period.closingDate', ':date_to'), $qb->expr()->lte('acp.closingDate', ':date_to'),
$qb->expr()->gte('accompanying_period.closingDate', ':date_from') $qb->expr()->gte('acp.closingDate', ':date_from')
); );
$qb->andWhere($clause); $qb->andWhere($clause);

View File

@ -34,12 +34,12 @@ class AccompanyingPeriodFilter extends AbstractAccompanyingPeriodExportElement i
$clause = $qb->expr()->andX(); $clause = $qb->expr()->andX();
$clause->add( $clause->add(
$qb->expr()->lte('accompanying_period.openingDate', ':date_to') $qb->expr()->lte('acp.openingDate', ':date_to')
); );
$clause->add( $clause->add(
$qb->expr()->orX( $qb->expr()->orX(
$qb->expr()->gte('accompanying_period.closingDate', ':date_from'), $qb->expr()->gte('acp.closingDate', ':date_from'),
$qb->expr()->isNull('accompanying_period.closingDate') $qb->expr()->isNull('acp.closingDate')
) )
); );

View File

@ -32,8 +32,8 @@ class AccompanyingPeriodOpeningFilter extends AbstractAccompanyingPeriodExportEl
$this->addJoinAccompanyingPeriod($qb); $this->addJoinAccompanyingPeriod($qb);
$clause = $qb->expr()->andX( $clause = $qb->expr()->andX(
$qb->expr()->lte('accompanying_period.openingDate', ':date_to'), $qb->expr()->lte('acp.openingDate', ':date_to'),
$qb->expr()->gte('accompanying_period.openingDate', ':date_from') $qb->expr()->gte('acp.openingDate', ':date_from')
); );
$qb->andWhere($clause); $qb->andWhere($clause);