Fixing missing table aliases when using Many2Many persister.
This commit is contained in:
parent
44f9952063
commit
09d51f9df5
@ -235,7 +235,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
foreach ($joinColumns as $joinColumn) {
|
||||
$columnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform);
|
||||
$referencedName = $joinColumn['referencedColumnName'];
|
||||
$conditions[] = $columnName . ' = ?';
|
||||
$conditions[] = 't.' . $columnName . ' = ?';
|
||||
$params[] = ($class->containsForeignIdentifier)
|
||||
? $id[$class->getFieldForColumn($referencedName)]
|
||||
: $id[$class->fieldNames[$referencedName]];
|
||||
@ -361,12 +361,13 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
$params = array();
|
||||
|
||||
foreach ($mapping['joinTableColumns'] as $joinTableColumn) {
|
||||
$whereClauses[] = $joinTableColumn . ' = ?';
|
||||
$whereClauses[] = ($addFilters ? 't.' : '') . $joinTableColumn . ' = ?';
|
||||
|
||||
if (isset($mapping['relationToTargetKeyColumns'][$joinTableColumn])) {
|
||||
$params[] = ($targetClass->containsForeignIdentifier)
|
||||
? $targetId[$targetClass->getFieldForColumn($mapping['relationToTargetKeyColumns'][$joinTableColumn])]
|
||||
: $targetId[$targetClass->fieldNames[$mapping['relationToTargetKeyColumns'][$joinTableColumn]]];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -377,9 +378,12 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
}
|
||||
|
||||
if ($addFilters) {
|
||||
$quotedJoinTable .= ' t';
|
||||
|
||||
list($joinTargetEntitySQL, $filterSql) = $this->getFilterSql($filterMapping);
|
||||
|
||||
if ($filterSql) {
|
||||
$quotedJoinTable .= ' t ' . $joinTargetEntitySQL;
|
||||
$quotedJoinTable .= ' ' . $joinTargetEntitySQL;
|
||||
$whereClauses[] = $filterSql;
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class DDC1595Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$entities = $entity1->getEntities()->count();
|
||||
|
||||
$this->assertEquals(
|
||||
"SELECT COUNT(*) FROM entity1_entity2 t WHERE parent = ?",
|
||||
"SELECT COUNT(*) FROM entity1_entity2 t WHERE t.parent = ?",
|
||||
$sqlLogger->queries[count($sqlLogger->queries)]['sql']
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user