1
0
mirror of synced 2024-12-13 22:56:04 +03:00
Ticket: 157
This commit is contained in:
zYne 2006-10-10 18:09:20 +00:00
parent d83c193b1a
commit 5957622575
3 changed files with 24 additions and 6 deletions

View File

@ -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;

View File

@ -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;
}
/**

View File

@ -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();