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 44fa8bb commit 0884434
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 @@ -1332,6 +1332,12 @@ protected function getSelectColumnsSQL(): string
$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 @@ -559,6 +559,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 0884434

Please sign in to comment.