This commit is contained in:
parent
f290439c52
commit
e1979612c7
@ -696,11 +696,11 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
|
||||
*/
|
||||
public function getQuery($params = array())
|
||||
{
|
||||
if ($this->_state !== self::STATE_DIRTY) {
|
||||
return $this->_sql;
|
||||
}
|
||||
if ($this->_state !== self::STATE_DIRTY) {
|
||||
return $this->_sql;
|
||||
}
|
||||
|
||||
$parts = $this->_dqlParts;
|
||||
$parts = $this->_dqlParts;
|
||||
|
||||
// reset the state
|
||||
$this->_aliasMap = array();
|
||||
@ -928,7 +928,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
|
||||
$subquery = $this->_conn->modifyLimitQuery($subquery, $this->parts['limit'], $this->parts['offset']);
|
||||
|
||||
$parts = Doctrine_Tokenizer::quoteExplode($subquery, ' ', "'", "'");
|
||||
|
||||
//print_r($parts);
|
||||
foreach ($parts as $k => $part) {
|
||||
if (strpos($part, "'") !== false) {
|
||||
continue;
|
||||
@ -936,8 +936,43 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
|
||||
|
||||
if ($this->hasTableAlias($part)) {
|
||||
$parts[$k] = $this->generateNewTableAlias($part);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strpos($part, '.') == false) {
|
||||
continue;
|
||||
}
|
||||
preg_match_all("/[a-zA-Z0-9_]+\.[a-z0-9_]+/i", $part, $m);
|
||||
|
||||
foreach ($m[0] as $match) {
|
||||
$e = explode('.', $match);
|
||||
$e[0] = $this->generateNewTableAlias($e[0]);
|
||||
|
||||
$parts[$k] = str_replace($match, implode('.', $e), $parts[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($driverName == 'mysql' || $driverName == 'pgsql') {
|
||||
foreach ($parts as $k => $part) {
|
||||
if (strpos($part, "'") !== false) {
|
||||
continue;
|
||||
}
|
||||
if (strpos($part, '__') == false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
preg_match_all("/[a-zA-Z0-9_]+\_\_[a-z0-9_]+/i", $part, $m);
|
||||
|
||||
foreach ($m[0] as $match) {
|
||||
$e = explode('__', $match);
|
||||
$e[0] = $this->generateNewTableAlias($e[0]);
|
||||
|
||||
$parts[$k] = str_replace($match, implode('__', $e), $parts[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
||||
$separator = false;
|
||||
|
||||
if (strpos($part, '.') !== false) {
|
||||
@ -958,8 +993,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
|
||||
|
||||
$e[0] = substr($e[0], 0, $pos) . $this->generateNewTableAlias($trimmed);
|
||||
$parts[$k] = implode($separator, $e);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
$subquery = implode(' ', $parts);
|
||||
|
||||
return $subquery;
|
||||
|
@ -52,7 +52,7 @@ class Doctrine_Query_MysqlSubqueryHaving_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$this->dbh->pop();
|
||||
|
||||
$this->assertEqual($this->dbh->pop(), 'SELECT DISTINCT e2.id, COUNT(DISTINCT a2.id) AS a2__0 FROM entity e2 LEFT JOIN album a2 ON e2.id = a2.user_id WHERE (e2.type = 0) GROUP BY e2.id HAVING a2__0 > 0 ORDER BY a2__0 LIMIT 5');
|
||||
$this->assertEqual($this->dbh->pop(), 'SELECT DISTINCT e2.id, COUNT(DISTINCT a2.id) AS a2__0 FROM entity e2 LEFT JOIN album a2 ON e2.id = a2.user_id WHERE (e2.type = 0) GROUP BY e2.id HAVING a2__0 > 0 ORDER BY a2__0 DESC LIMIT 5');
|
||||
}
|
||||
|
||||
public function testGetLimitSubqueryWithHavingOnAggregateValuesIncorrectAlias()
|
||||
@ -68,7 +68,6 @@ class Doctrine_Query_MysqlSubqueryHaving_TestCase extends Doctrine_UnitTestCase
|
||||
$q->execute();
|
||||
|
||||
$this->dbh->pop();
|
||||
|
||||
$this->assertEqual($this->dbh->pop(), 'SELECT DISTINCT e2.id, COUNT(a2.id) AS a2__0 FROM entity e2 LEFT JOIN album a2 ON e2.id = a2.user_id WHERE (e2.type = 0) GROUP BY e2.id HAVING a2__0 > 0 ORDER BY a2__0 LIMIT 5');
|
||||
$this->assertEqual($this->dbh->pop(), 'SELECT DISTINCT e2.id, COUNT(a2.id) AS a2__0 FROM entity e2 LEFT JOIN album a2 ON e2.id = a2.user_id WHERE (e2.type = 0) GROUP BY e2.id HAVING a2__0 > 0 ORDER BY a2__0 DESC LIMIT 5');
|
||||
}
|
||||
}
|
@ -70,7 +70,7 @@ $test = new GroupTest('Doctrine Framework Unit Tests');
|
||||
|
||||
$test->addTestCase(new Doctrine_Ticket330_TestCase());
|
||||
*/
|
||||
/** */
|
||||
/** */
|
||||
// Connection drivers (not yet fully tested)
|
||||
$test->addTestCase(new Doctrine_Connection_Pgsql_TestCase());
|
||||
$test->addTestCase(new Doctrine_Connection_Oracle_TestCase());
|
||||
|
Loading…
x
Reference in New Issue
Block a user