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 1486646
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 @@ -537,6 +537,21 @@ public function testToOneFilter(): void
self::assertEquals(2, count($query->getResult()));
}

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);
}

public function testManyToManyFilter(): void
{
$this->loadFixtureData();
Expand Down

0 comments on commit 1486646

Please sign in to comment.