1
0
mirror of synced 2025-01-06 00:57:10 +03:00

Fixed pgsql limit subquery algorithm

This commit is contained in:
zYne 2006-11-01 17:08:35 +00:00
parent 6b4e032857
commit b75ef330d4

View File

@ -533,13 +533,19 @@ 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();
$primaryKey = $table->getTableName() . '.' . $table->getIdentifier();
// initialize the base of the subquery
$subquery = 'SELECT DISTINCT ' . $primaryKey;
if($this->connection->getDBH()->getAttribute(PDO::ATTR_DRIVER_NAME) == 'pgsql') {
// pgsql needs the order by fields to be preserved in select clause
foreach($this->parts['orderby'] as $part) {
$e = explode(' ', $part);
// don't add primarykey column (its already in the select clause)
if($e[0] !== $primaryKey)
$subquery .= ', ' . $e[0];
}
}