Commit 8ed0530f authored by romanb's avatar romanb

Fixed #626.

parent 28fba54f
...@@ -1588,7 +1588,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria ...@@ -1588,7 +1588,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria
$queryPart .= ' ON ' . $localAlias $queryPart .= ' ON ' . $localAlias
. '.' . '.'
. $localTable->getIdentifier() // what about composite keys? . $localTable->getColumnName($localTable->getIdentifier()) // what about composite keys?
. ' = ' . ' = '
. $assocAlias . '.' . $relation->getLocal(); . $assocAlias . '.' . $relation->getLocal();
...@@ -1612,7 +1612,8 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria ...@@ -1612,7 +1612,8 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria
$queryPart .= '('; $queryPart .= '(';
} }
$queryPart .= $this->_conn->quoteIdentifier($foreignAlias . '.' . $relation->getTable()->getIdentifier()) $relationTable = $relation->getTable();
$queryPart .= $this->_conn->quoteIdentifier($foreignAlias . '.' . $relationTable->getColumnName($relationTable->getIdentifier()))
. ' = ' . ' = '
. $this->_conn->quoteIdentifier($assocAlias . '.' . $relation->getForeign()); . $this->_conn->quoteIdentifier($assocAlias . '.' . $relation->getForeign());
...@@ -1622,9 +1623,9 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria ...@@ -1622,9 +1623,9 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria
. ' = ' . ' = '
. $this->_conn->quoteIdentifier($assocAlias . '.' . $relation->getLocal()) . $this->_conn->quoteIdentifier($assocAlias . '.' . $relation->getLocal())
. ') AND ' . ') AND '
. $this->_conn->quoteIdentifier($foreignAlias . '.' . $table->getIdentifier()) . $this->_conn->quoteIdentifier($foreignAlias . '.' . $table->getColumnName($table->getIdentifier()))
. ' != ' . ' != '
. $this->_conn->quoteIdentifier($localAlias . '.' . $table->getIdentifier()); . $this->_conn->quoteIdentifier($localAlias . '.' . $table->getColumnName($table->getIdentifier()));
} }
} }
} else { } else {
...@@ -1794,7 +1795,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria ...@@ -1794,7 +1795,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria
// build the query base // build the query base
$q = 'SELECT COUNT(DISTINCT ' . $this->getTableAlias($componentAlias) $q = 'SELECT COUNT(DISTINCT ' . $this->getTableAlias($componentAlias)
. '.' . implode(',', (array) $table->getIdentifier()) . '.' . implode(',', $table->getIdentifierColumnNames())
. ') AS num_results'; . ') AS num_results';
foreach ($this->_sqlParts['select'] as $field) { foreach ($this->_sqlParts['select'] as $field) {
......
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