Skip to content

Commit

Permalink
[DDC-551] fix, add filter support in oneToOne relation
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenMartens committed Nov 7, 2024
1 parent 9e2bfa8 commit fdef7ec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Persisters/Entity/BasicEntityPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,12 @@ protected function getSelectColumnsSQL()
$joinCondition[] = $this->getSQLTableAlias($association['sourceEntity'], $assocAlias) . '.' . $sourceCol . ' = '
. $this->getSQLTableAlias($association['targetEntity']) . '.' . $targetCol;
}

// Add filter SQL
$filterSql = $this->generateFilterConditionSQL($eagerEntity, $joinTableAlias);
if ($filterSql) {
$joinCondition[] = $filterSql;
}
}

$this->currentPersisterContext->selectJoinSql .= ' ' . $joinTableName . ' ' . $joinTableAlias . ' ON ';
Expand Down
15 changes: 15 additions & 0 deletions tests/Tests/ORM/Functional/SQLFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,21 @@ private function loadLazyFixtureData(): void
$this->loadFixtureData();
}

public function testOneToOneInverseSideWithFilter(): void
{
$this->loadFixtureData();

$conf = $this->_em->getConfiguration();
$conf->addFilter('country', '\Doctrine\Tests\ORM\Functional\CMSCountryFilter');
$this->_em->getFilters()->enable('country')->setParameterList('country', ['Germany'], Types::STRING);

$user = $this->_em->find(CmsUser::class, $this->userId);
self::assertNotEmpty($user->address);

$user2 = $this->_em->find(CmsUser::class, $this->userId2);
self::assertEmpty($user2->address);
}

private function useCMSArticleTopicFilter(): void
{
$conf = $this->_em->getConfiguration();
Expand Down

0 comments on commit fdef7ec

Please sign in to comment.