Commit e1979612 authored by zYne's avatar zYne

--no commit message

--no commit message
parent f290439c
......@@ -307,7 +307,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
} else {
$this->setQueryPart($queryPartName, $sql);
}
}
}
}
$this->_state = Doctrine_Query::STATE_DIRTY;
......@@ -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,16 +928,51 @@ 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;
}
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');
}
}
\ No newline at end of file
}
......@@ -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());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment