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