Permalink
Browse files

Merge pull request #502 from gwis/master

 Fix for invalid 'double-ON' SQL generation with entity inheritance type JOINED.
  • Loading branch information...
guilhermeblanco committed Nov 6, 2012
2 parents 283ed55 + 9e916a2 commit 7a895209e3d9912bcc44fc8e8635dd48164a4749
@@ -1032,8 +1032,13 @@ public function walkJoin($join)
switch (true) {
case ($joinDeclaration instanceof \Doctrine\ORM\Query\AST\RangeVariableDeclaration):
+ $class = $this->em->getClassMetadata($joinDeclaration->abstractSchemaName);
+ $condExprConjunction = $class->isInheritanceTypeJoined()
+ ? ' AND '
+ : ' ON ';
+
$sql .= $this->walkRangeVariableDeclaration($joinDeclaration)
- . ' ON (' . $this->walkConditionalExpression($join->conditionalExpression) . ')';
+ . $condExprConjunction . '(' . $this->walkConditionalExpression($join->conditionalExpression) . ')';
break;
case ($joinDeclaration instanceof \Doctrine\ORM\Query\AST\JoinAssociationDeclaration):
@@ -143,6 +143,14 @@ public function testSupportsJoinOnMultipleComponents()
);
}
+ public function testSupportsJoinOnMultipleComponentsWithJoinedInheritanceType()
+ {
+ $this->assertSqlGeneration(
+ 'SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e JOIN Doctrine\Tests\Models\Company\CompanyManager m WITH e.id = m.id',
+ 'SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c1_.startDate AS startDate4, c0_.discr AS discr5 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id INNER JOIN company_managers c2_ INNER JOIN company_employees c3_ ON c2_.id = c3_.id INNER JOIN company_persons c4_ ON c2_.id = c4_.id AND (c0_.id = c4_.id)'
+ );
+ }
+
public function testSupportsSelectWithCollectionAssociationJoin()
{
$this->assertSqlGeneration(

0 comments on commit 7a89520

Please sign in to comment.