Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DDC-551] fix, add filter support in oneToOne relation 3.3.x #11708

Open
wants to merge 1 commit into
base: 3.3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -503,6 +503,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