Commit 59576225 authored by zYne's avatar zYne

Fixes #157

Ticket: 157
parent d83c193b
......@@ -204,7 +204,10 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
* @param string $path
* @return string
*/
final public function getTableAlias($path) {
final public function getTableAlias($path) {
if(isset($this->compAliases[$path]))
$path = $this->compAliases[$path];
if( ! isset($this->tableAliases[$path]))
return false;
......
......@@ -650,14 +650,13 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
}
return $term;
}
/**
* generateAlias
*
* @param string $tableName
* @return string
*/
final public function generateAlias($tableName) {
public function generateAlias($tableName) {
if(isset($this->tableIndexes[$tableName])) {
return $tableName.++$this->tableIndexes[$tableName];
} else {
......@@ -688,9 +687,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
} else
$path = $tmp[0];
if($componentAlias !== false) {
$this->compAliases[$componentAlias] = $path;
}
$index = 0;
$currPath = '';
......@@ -816,6 +813,11 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
throw new Doctrine_Query_Exception($e->__toString());
}
}
if($componentAlias !== false) {
$this->compAliases[$componentAlias] = $currPath;
}
return $table;
}
/**
......
......@@ -5,6 +5,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase {
$this->tables = array('entity');
parent::prepareTables();
}
public function testDirectParameterSetting() {
$this->connection->clear();
......@@ -36,6 +37,18 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase {
$this->assertEqual($users[0]->name, 'someone');
$this->assertEqual($users[1]->name, 'someone.2');
}
public function testComponentAliases() {
$q = new Doctrine_Query();
$q = new Doctrine_Query();
$q->from('User(id) u')->addWhere('u.id IN (?, ?)',array(1,2));
$users = $q->execute();
$this->assertEqual($users->count(), 2);
$this->assertEqual($users[0]->name, 'someone');
$this->assertEqual($users[1]->name, 'someone.2');
}
public function testOperatorWithNoTrailingSpaces() {
$q = new Doctrine_Query();
......
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