Fixes in ParserResult, which was generating a bad table alias. Added more test cases. Commented new Event system call in EntityManager. Fixes in RangeVariableDeclaration.
This commit is contained in:
parent
6f1d5723e7
commit
d8d761b593
@ -140,7 +140,7 @@ class Doctrine_EntityManager
|
|||||||
$this->_metadataFactory = new Doctrine_ClassMetadata_Factory(
|
$this->_metadataFactory = new Doctrine_ClassMetadata_Factory(
|
||||||
$this, new Doctrine_ClassMetadata_CodeDriver());
|
$this, new Doctrine_ClassMetadata_CodeDriver());
|
||||||
$this->_unitOfWork = new Doctrine_Connection_UnitOfWork($conn);
|
$this->_unitOfWork = new Doctrine_Connection_UnitOfWork($conn);
|
||||||
$this->_eventManager = new Doctrine_EventManager();
|
//$this->_eventManager = new Doctrine_EventManager();
|
||||||
|
|
||||||
if ($name !== null) {
|
if ($name !== null) {
|
||||||
self::$_ems[$name] = $this;
|
self::$_ems[$name] = $this;
|
||||||
|
@ -142,6 +142,12 @@ class Doctrine_Query_ParserResult extends Doctrine_Query_AbstractResult
|
|||||||
{
|
{
|
||||||
$baseAlias = strtolower(preg_replace('/[^A-Z]/', '\\1', $componentName));
|
$baseAlias = strtolower(preg_replace('/[^A-Z]/', '\\1', $componentName));
|
||||||
|
|
||||||
|
// We may have a situation where we have all chars are lowercased
|
||||||
|
if ( $baseAlias == '' ) {
|
||||||
|
// We simply grab the first 2 chars of component name
|
||||||
|
$baseAlias = substr($componentNam, 0, 2);
|
||||||
|
}
|
||||||
|
|
||||||
$alias = $baseAlias;
|
$alias = $baseAlias;
|
||||||
|
|
||||||
if ( ! isset($this->_tableAliasSeeds[$baseAlias])) {
|
if ( ! isset($this->_tableAliasSeeds[$baseAlias])) {
|
||||||
|
@ -144,7 +144,7 @@ class Doctrine_Query_Production_RangeVariableDeclaration extends Doctrine_Query_
|
|||||||
|
|
||||||
//echo "Identification Variable: " .$this->_identificationVariable . "\n";
|
//echo "Identification Variable: " .$this->_identificationVariable . "\n";
|
||||||
|
|
||||||
$tableAlias = $parserResult->generateTableAlias($componentName);
|
$tableAlias = $parserResult->generateTableAlias($classMetadata->getClassName());
|
||||||
$parserResult->setQueryComponent($this->_identificationVariable, $queryComponent);
|
$parserResult->setQueryComponent($this->_identificationVariable, $queryComponent);
|
||||||
$parserResult->setTableAlias($tableAlias, $this->_identificationVariable);
|
$parserResult->setTableAlias($tableAlias, $this->_identificationVariable);
|
||||||
}
|
}
|
||||||
@ -216,7 +216,7 @@ class Doctrine_Query_Production_RangeVariableDeclaration extends Doctrine_Query_
|
|||||||
|
|
||||||
$parent = $path;
|
$parent = $path;
|
||||||
} catch (Doctrine_Exception $e) {
|
} catch (Doctrine_Exception $e) {
|
||||||
//echo "Tried to load class metadata from '".$relationName."'\n";
|
echo "Tried to load class metadata from '".$relationName."'\n";
|
||||||
$this->_parser->semanticalError($e->getMessage());
|
$this->_parser->semanticalError($e->getMessage());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -228,7 +228,10 @@ class Doctrine_Query_Production_RangeVariableDeclaration extends Doctrine_Query_
|
|||||||
$this->_identificationVariable = $path;
|
$this->_identificationVariable = $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tableAlias = $parserResult->generateTableAlias($path);
|
$tableAlias = $parserResult->generateTableAlias($classMetadata->getClassName());
|
||||||
|
|
||||||
|
//echo "Table alias: " . $tableAlias . "\n";
|
||||||
|
|
||||||
$parserResult->setQueryComponent($this->_identificationVariable, $queryComponent);
|
$parserResult->setQueryComponent($this->_identificationVariable, $queryComponent);
|
||||||
$parserResult->setTableAlias($tableAlias, $this->_identificationVariable);
|
$parserResult->setTableAlias($tableAlias, $this->_identificationVariable);
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ class Orm_Query_SelectSqlGenerationTest extends Doctrine_OrmTestCase
|
|||||||
//echo print_r($query->parse()->getQueryFields(), true) . "\n";
|
//echo print_r($query->parse()->getQueryFields(), true) . "\n";
|
||||||
|
|
||||||
parent::assertEquals($sqlToBeConfirmed, $query->getSql());
|
parent::assertEquals($sqlToBeConfirmed, $query->getSql());
|
||||||
|
//echo $query->getSql() . "\n";
|
||||||
|
|
||||||
$query->free();
|
$query->free();
|
||||||
} catch (Doctrine_Exception $e) {
|
} catch (Doctrine_Exception $e) {
|
||||||
@ -93,17 +94,15 @@ class Orm_Query_SelectSqlGenerationTest extends Doctrine_OrmTestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Not supported yet!
|
|
||||||
|
|
||||||
public function testSelectMultipleComponentsWithAsterisk()
|
public function testSelectMultipleComponentsWithAsterisk()
|
||||||
{
|
{
|
||||||
$this->assertSqlGeneration(
|
$this->assertSqlGeneration(
|
||||||
'SELECT u.*, p.* FROM CmsUser u, u.phonenumbers p',
|
'SELECT u.*, p.* FROM CmsUser u, u.phonenumbers p',
|
||||||
'SELECT cu.id AS cu__id, cu.status AS cu__status, cu.username AS cu__username, cu.name AS cu__name FROM cms_user cu WHERE 1 = 1'
|
'SELECT cu.id AS cu__id, cu.status AS cu__status, cu.username AS cu__username, cu.name AS cu__name, cp.user_id AS cp__user_id, cp.phonenumber AS cp__phonenumber FROM cms_user cu, cms_phonenumber cp WHERE 1 = 1'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
public function testSelectDistinctIsSupported()
|
public function testSelectDistinctIsSupported()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user