Commit d0c0592e authored by zYne's avatar zYne

Little fix for preserving fields on pgsql when limit subquery with orderby is used

parent dd73f6de
......@@ -498,7 +498,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
break;
}
$field = $table->getTableName().'.'.$table->getIdentifier();
$field = $table->getTableName() . '.' . $table->getIdentifier();
array_unshift($this->parts['where'], $field. ' IN (' . $subquery . ')');
$modifyLimit = false;
}
......@@ -533,9 +533,18 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
$k = array_keys($this->tables);
$table = $this->tables[$k[0]];
$subquery = 'SELECT DISTINCT ' . $table->getTableName()
. '.' . $table->getIdentifier()
. ' FROM '.$table->getTableName();
$subquery = 'SELECT DISTINCT ' . $table->getTableName()
. '.' . $table->getIdentifier();
if($this->connection->getDBH()->getAttribute(PDO::ATTR_DRIVER_NAME) == 'pgsql') {
foreach($this->parts['orderby'] as $part) {
$e = explode(' ', $part);
$subquery .= ', ' . $e[0];
}
}
$subquery .= ' FROM '.$table->getTableName();
foreach($this->parts['join'] as $parts) {
foreach($parts as $part) {
......
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