1
0
mirror of synced 2025-03-27 02:13:50 +03:00

fixes #515, correlated subqueries with IN operator

This commit is contained in:
zYne 2007-10-29 18:04:22 +00:00
parent 991f456fa4
commit dc5e0cee32
2 changed files with 11 additions and 2 deletions

View File

@ -74,7 +74,7 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition
$alias = $this->query->getTableAlias($reference);
$table = $map['table'];
}
}
}
$first = $this->query->parseClause($first);
@ -97,7 +97,7 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition
// subquery found
$q = new Doctrine_Query();
$value = '(' . $q->isSubquery(true)->parseQuery($trimmed)->getQuery() . ')';
$value = '(' . $this->query->createSubquery()->parseQuery($trimmed, false)->getQuery() . ')';
} elseif (substr($trimmed, 0, 4) == 'SQL:') {
$value = '(' . substr($trimmed, 4) . ')';

View File

@ -315,4 +315,13 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($q->getSql(), 'SELECT e.id AS e__id FROM entity e WHERE 1 IN (1, 2) AND (e.type = 0)');
}
public function testCorrelatedSubqueryWithInOperatorIsSupported()
{
$q = new Doctrine_Query();
$q->select('u.id')->from('User u')->where('u.name IN (SELECT u2.name FROM User u2 WHERE u2.id = u.id)');
$this->assertEqual($q->getSql(), 'SELECT e.id AS e__id FROM entity e WHERE e.name IN (SELECT e2.name AS e2__name FROM entity e2 WHERE e2.id = e.id AND (e.type = 0 AND (e2.type = 0 OR e2.type IS NULL))) AND (e.type = 0)');
}
}