1
0
mirror of synced 2024-12-14 15:16:04 +03:00

[2.0][DDC-479] Fixed.

This commit is contained in:
romanb 2010-03-26 22:07:31 +00:00
parent 6b86c97f0a
commit 49621286a2
2 changed files with 12 additions and 12 deletions

View File

@ -1349,33 +1349,33 @@ class SqlWalker implements TreeWalker
// join conditions // join conditions
$joinColumns = $assoc->isOwningSide $joinColumns = $assoc->isOwningSide
? $joinTable['joinColumns'] ? $joinTable['inverseJoinColumns']
: $joinTable['inverseJoinColumns']; : $joinTable['joinColumns'];
$referencedColumnClass = $assoc->isOwningSide ? $class : $targetClass; //$referencedColumnClass = $assoc->isOwningSide ? $targetClass : $class;
$first = true; $first = true;
foreach ($joinColumns as $joinColumn) { foreach ($joinColumns as $joinColumn) {
if ($first) $first = false; else $sql .= ' AND '; if ($first) $first = false; else $sql .= ' AND ';
$sql .= $joinTableAlias . '.' . $joinColumn['name'] . ' = ' $sql .= $joinTableAlias . '.' . $joinColumn['name'] . ' = '
. $sourceTableAlias . '.' . $referencedColumnClass->getQuotedColumnName( . $targetTableAlias . '.' . $targetClass->getQuotedColumnName(
$referencedColumnClass->fieldNames[$joinColumn['referencedColumnName']], $targetClass->fieldNames[$joinColumn['referencedColumnName']],
$this->_platform); $this->_platform);
} }
$sql .= ' WHERE '; $sql .= ' WHERE ';
$joinColumns = $assoc->isOwningSide $joinColumns = $assoc->isOwningSide
? $joinTable['inverseJoinColumns'] ? $joinTable['joinColumns']
: $joinTable['joinColumns']; : $joinTable['inverseJoinColumns'];
$first = true; $first = true;
foreach ($joinColumns as $joinColumn) { foreach ($joinColumns as $joinColumn) {
if ($first) $first = false; else $sql .= ' AND '; if ($first) $first = false; else $sql .= ' AND ';
$sql .= $joinTableAlias . '.' . $joinColumn['name'] . ' = ' $sql .= $joinTableAlias . '.' . $joinColumn['name'] . ' = '
. $targetTableAlias . '.' . $referencedColumnClass->getQuotedColumnName( . $sourceTableAlias . '.' . $class->getQuotedColumnName(
$referencedColumnClass->fieldNames[$joinColumn['referencedColumnName']], $class->fieldNames[$joinColumn['referencedColumnName']],
$this->_platform); $this->_platform);
} }

View File

@ -348,7 +348,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
$q2->setParameter('param', $group); $q2->setParameter('param', $group);
$this->assertEquals( $this->assertEquals(
'SELECT c0_.id AS id0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_users_groups c1_ INNER JOIN cms_groups c2_ ON c1_.user_id = c0_.id WHERE c1_.group_id = c2_.id AND c2_.id = ?)', 'SELECT c0_.id AS id0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_users_groups c1_ INNER JOIN cms_groups c2_ ON c1_.group_id = c2_.id WHERE c1_.user_id = c0_.id AND c2_.id = ?)',
$q2->getSql() $q2->getSql()
); );
@ -359,7 +359,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
$this->_em->getClassMetadata(get_class($person))->setIdentifierValues($person, 101); $this->_em->getClassMetadata(get_class($person))->setIdentifierValues($person, 101);
$q3->setParameter('param', $person); $q3->setParameter('param', $person);
$this->assertEquals( $this->assertEquals(
'SELECT c0_.id AS id0, c0_.name AS name1, c1_.title AS title2, c1_.car_id AS car_id3, c2_.salary AS salary4, c2_.department AS department5, c0_.discr AS discr6, c0_.spouse_id AS spouse_id7 FROM company_persons c0_ LEFT JOIN company_managers c1_ ON c0_.id = c1_.id LEFT JOIN company_employees c2_ ON c0_.id = c2_.id WHERE EXISTS (SELECT 1 FROM company_persons_friends c3_ INNER JOIN company_persons c4_ ON c3_.person_id = c0_.id WHERE c3_.friend_id = c4_.id AND c4_.id = ?)', 'SELECT c0_.id AS id0, c0_.name AS name1, c1_.title AS title2, c1_.car_id AS car_id3, c2_.salary AS salary4, c2_.department AS department5, c0_.discr AS discr6, c0_.spouse_id AS spouse_id7 FROM company_persons c0_ LEFT JOIN company_managers c1_ ON c0_.id = c1_.id LEFT JOIN company_employees c2_ ON c0_.id = c2_.id WHERE EXISTS (SELECT 1 FROM company_persons_friends c3_ INNER JOIN company_persons c4_ ON c3_.friend_id = c4_.id WHERE c3_.person_id = c0_.id AND c4_.id = ?)',
$q3->getSql() $q3->getSql()
); );
} }