Commit 4570b900 authored by zYne's avatar zYne

fixed CTI column referencing within DQL

parent 0cda3678
...@@ -489,6 +489,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria ...@@ -489,6 +489,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria
$fields = $this->_pendingFields[$componentAlias]; $fields = $this->_pendingFields[$componentAlias];
// check for wildcards // check for wildcards
if (in_array('*', $fields)) { if (in_array('*', $fields)) {
//echo "<br />";Doctrine::dump($table->getColumnNames()); echo "<br />"; //echo "<br />";Doctrine::dump($table->getColumnNames()); echo "<br />";
...@@ -563,16 +564,14 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria ...@@ -563,16 +564,14 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria
return implode(', ', $sql); return implode(', ', $sql);
} else { } else {
$name = $table->getColumnName($field);
$this->_neededTables[] = $tableAlias;
return $this->_conn->quoteIdentifier($tableAlias . '.' . $name)
. ' AS '
. $this->_conn->quoteIdentifier($tableAlias . '__' . $name);
} }
$name = $table->getColumnName($field);
$this->_neededTables[] = $tableAlias;
return $this->_conn->quoteIdentifier($tableAlias . '.' . $name)
. ' AS '
. $this->_conn->quoteIdentifier($tableAlias . '__' . $name);
} }
/** /**
...@@ -765,15 +764,21 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria ...@@ -765,15 +764,21 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria
} }
$table = $this->_queryComponents[$componentAlias]['table']; $table = $this->_queryComponents[$componentAlias]['table'];
$def = $table->getDefinitionOf($field);
// get the actual field name from alias // get the actual field name from alias
$field = $table->getColumnName($field); $field = $table->getColumnName($field);
// check column existence // check column existence
if ( ! $table->hasColumn($field)) { if ( ! $def) {
throw new Doctrine_Query_Exception('Unknown column ' . $field); throw new Doctrine_Query_Exception('Unknown column ' . $field);
} }
if (isset($def['owner'])) {
$componentAlias = $componentAlias . '.' . $def['owner'];
}
$tableAlias = $this->getTableAlias($componentAlias); $tableAlias = $this->getTableAlias($componentAlias);
// build sql expression // build sql expression
...@@ -802,10 +807,20 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria ...@@ -802,10 +807,20 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria
// check column existence // check column existence
if ($table->hasColumn($term[0])) { if ($table->hasColumn($term[0])) {
$found = true; $found = true;
// get the actual field name from alias
$def = $table->getDefinitionOf($term[0]);
// get the actual column name from alias
$term[0] = $table->getColumnName($term[0]); $term[0] = $table->getColumnName($term[0]);
if (isset($def['owner'])) {
$componentAlias = $componentAlias . '.' . $def['owner'];
}
$tableAlias = $this->getTableAlias($componentAlias);
$tableAlias = $this->getTableAlias($componentAlias); $tableAlias = $this->getTableAlias($componentAlias);
if ($this->getType() === Doctrine_Query::SELECT) { if ($this->getType() === Doctrine_Query::SELECT) {
......
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