From bc236c59da70c8f8859ac825d99f6614a7e246bd Mon Sep 17 00:00:00 2001 From: guilhermeblanco Date: Tue, 27 May 2008 03:44:08 +0000 Subject: [PATCH] Finished first parts of SELECT support. Two test cases added and passing. Introduced the concept of DCTRN in queryComponent. Added concept of queryField, which validates for already defined fields in SELECT. --- lib/Doctrine/Query/AbstractResult.php | 12 +++ lib/Doctrine/Query/Parser.php | 17 +++- lib/Doctrine/Query/ParserResult.php | 69 +++++++++++++ .../FieldIdentificationVariable.php | 62 ++++++++++++ .../Production/IdentificationVariable.php | 1 + .../Query/Production/PathExpression.php | 8 +- .../PathExpressionEndingWithAsterisk.php | 93 ++++++++++++++---- .../Production/RangeVariableDeclaration.php | 6 +- .../Query/Production/SelectExpression.php | 98 ++++++++++++++----- .../Query/Production/VariableDeclaration.php | 2 +- query-language.txt | 4 +- tests/Orm/Query/IdentifierRecognitionTest.php | 14 +-- tests/Orm/Query/LanguageRecognitionTest.php | 2 +- tests/Orm/Query/SelectSqlGenerationTest.php | 6 +- 14 files changed, 326 insertions(+), 68 deletions(-) create mode 100755 lib/Doctrine/Query/Production/FieldIdentificationVariable.php diff --git a/lib/Doctrine/Query/AbstractResult.php b/lib/Doctrine/Query/AbstractResult.php index 53e9d5ecc..03d510c9e 100755 --- a/lib/Doctrine/Query/AbstractResult.php +++ b/lib/Doctrine/Query/AbstractResult.php @@ -131,6 +131,18 @@ abstract class Doctrine_Query_AbstractResult } + /** + * Get the component alias for a given query component + * + * @param array $queryComponent The query component + * @param string Component alias + */ + public function getComponentAlias($queryComponent) + { + return array_search($queryComponent, $this->_queryComponents);; + } + + /** * Whether or not this object has a declaration for given component alias. * diff --git a/lib/Doctrine/Query/Parser.php b/lib/Doctrine/Query/Parser.php index 220cbdafa..c5fafa1bd 100644 --- a/lib/Doctrine/Query/Parser.php +++ b/lib/Doctrine/Query/Parser.php @@ -114,10 +114,25 @@ class Doctrine_Query_Parser public function __construct($dql, Doctrine_Connection $connection = null) { $this->_scanner = new Doctrine_Query_Scanner($dql); - $this->_parserResult = new Doctrine_Query_ParserResult(); $this->_sqlBuilder = Doctrine_Query_SqlBuilder::fromConnection($connection); $this->_keywordTable = new Doctrine_Query_Token(); + $this->_parserResult = new Doctrine_Query_ParserResult( + '', + array( // queryComponent + 'dctrn' => array( + 'metadata' => null, + 'parent' => null, + 'relation' => null, + 'map' => null, + 'scalar' => null, + ), + ), + array( // tableAliasMap + 'dctrn' => 'dctrn', + ) + ); + $this->free(true); } diff --git a/lib/Doctrine/Query/ParserResult.php b/lib/Doctrine/Query/ParserResult.php index 93231293e..dd43926e3 100755 --- a/lib/Doctrine/Query/ParserResult.php +++ b/lib/Doctrine/Query/ParserResult.php @@ -43,6 +43,13 @@ class Doctrine_Query_ParserResult extends Doctrine_Query_AbstractResult */ protected $_tableAliasSeeds = array(); + /** + * Simple array of keys representing the fields used in query. + * + * @var array $_queryFields + */ + protected $_queryFields = array(); + /** * @nodoc @@ -62,6 +69,68 @@ class Doctrine_Query_ParserResult extends Doctrine_Query_AbstractResult } + /** + * Defines the mapping fields. + * + * @param array $queryFields Query fields. + */ + public function setQueryComponents(array $queryFields) + { + $this->_queryFields = $queryFields; + } + + + /** + * Sets the declaration for given field alias. + * + * @param string $fieldAlias The field alias to set the declaration to. + * @param string $queryField Alias declaration. + */ + public function setQueryField($fieldAlias, array $queryField) + { + $this->_queryFields[$fieldAlias] = $queryField; + } + + + /** + * Gets the mapping fields. + * + * @return array Query fields. + */ + public function getQueryFields() + { + return $this->_queryComponents; + } + + + /** + * Get the declaration for given field alias. + * + * @param string $fieldAlias The field alias the retrieve the declaration from. + * @return array Alias declaration. + */ + public function getQueryField($fieldAlias) + { + if ( ! isset($this->_queryFields[$fieldAlias])) { + throw new Doctrine_Query_Exception('Unknown query field ' . $fieldAlias); + } + + return $this->_queryFields[$fieldAlias]; + } + + + /** + * Whether or not this object has a declaration for given field alias. + * + * @param string $fieldAlias Field alias the retrieve the declaration from. + * @return boolean True if this object has given alias, otherwise false. + */ + public function hasQueryField($fieldAlias) + { + return isset($this->_queryFields[$fieldAlias]); + } + + /** * Generates a table alias from given table name and associates * it with given component alias diff --git a/lib/Doctrine/Query/Production/FieldIdentificationVariable.php b/lib/Doctrine/Query/Production/FieldIdentificationVariable.php new file mode 100755 index 000000000..e7184005b --- /dev/null +++ b/lib/Doctrine/Query/Production/FieldIdentificationVariable.php @@ -0,0 +1,62 @@ +. + */ + +/** + * FieldIdentificationVariable = identifier + * + * @package Doctrine + * @subpackage Query + * @author Janne Vanhala + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link http://www.phpdoctrine.org + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_Query_Production_FieldIdentificationVariable extends Doctrine_Query_Production +{ + protected $_componentAlias; + + + public function syntax($paramHolder) + { + // FieldIdentificationVariable = identifier + $this->_parser->match(Doctrine_Query_Token::T_IDENTIFIER); + $this->_fieldAlias = $this->_parser->token['value']; + } + + + public function semantical($paramHolder) + { + $parserResult = $this->_parser->getParserResult(); + + if ($parserResult->hasQueryField($this->_fieldAlias)) { + // We should throw semantical error if there's already a component for this alias + $queryComponent = $parserResult->getQueryField($this->_fieldAlias); + $fieldName = $queryComponent['fieldName']; + + $message = "Cannot re-declare field alias '{$this->_fieldAlias}'" + . "for '".$paramHolder->get('fieldName')."'. It was already declared for " + . "field '{$fieldName}'."; + + $this->_parser->semanticalError($message); + } + } +} diff --git a/lib/Doctrine/Query/Production/IdentificationVariable.php b/lib/Doctrine/Query/Production/IdentificationVariable.php index db6361c25..6a7ecc7cd 100644 --- a/lib/Doctrine/Query/Production/IdentificationVariable.php +++ b/lib/Doctrine/Query/Production/IdentificationVariable.php @@ -24,6 +24,7 @@ * * @package Doctrine * @subpackage Query + * @author Guilherme Blanco * @author Janne Vanhala * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link http://www.phpdoctrine.org diff --git a/lib/Doctrine/Query/Production/PathExpression.php b/lib/Doctrine/Query/Production/PathExpression.php index 26845bba0..6684995b4 100644 --- a/lib/Doctrine/Query/Production/PathExpression.php +++ b/lib/Doctrine/Query/Production/PathExpression.php @@ -37,7 +37,7 @@ class Doctrine_Query_Production_PathExpression extends Doctrine_Query_Production protected $_fieldName; - private $_queryComponent; + protected $_queryComponent; public function syntax($paramHolder) @@ -67,13 +67,13 @@ class Doctrine_Query_Production_PathExpression extends Doctrine_Query_Production $queryComponents = $parserResult->getQueryComponents(); // Check if we have more than one queryComponent defined - if (count($queryComponents) != 1) { + if (count($queryComponents) != 2) { $this->_parser->semanticalError("Undefined component alias for field '{$this->_fieldName}'", $this->_parser->token); } // Retrieve ClassMetadata $k = array_keys($queryComponents); - $componentAlias = $k[0]; + $componentAlias = $k[1]; $this->_queryComponent = $queryComponents[$componentAlias]; $classMetadata = $this->_queryComponent['metadata']; @@ -141,7 +141,7 @@ class Doctrine_Query_Production_PathExpression extends Doctrine_Query_Production // Retrieve ClassMetadata $k = array_keys($queryComponents); - $componentAlias = $k[0]; + $componentAlias = $k[1]; } // Generating the SQL piece diff --git a/lib/Doctrine/Query/Production/PathExpressionEndingWithAsterisk.php b/lib/Doctrine/Query/Production/PathExpressionEndingWithAsterisk.php index 637eb062a..bfbf1cc4c 100644 --- a/lib/Doctrine/Query/Production/PathExpressionEndingWithAsterisk.php +++ b/lib/Doctrine/Query/Production/PathExpressionEndingWithAsterisk.php @@ -34,6 +34,8 @@ class Doctrine_Query_Production_PathExpressionEndingWithAsterisk extends Doctrin { protected $_identifiers = array(); + protected $_queryComponent; + public function syntax($paramHolder) { @@ -55,37 +57,47 @@ class Doctrine_Query_Production_PathExpressionEndingWithAsterisk extends Doctrin if (($l = count($this->_identifiers)) > 0) { // We are dealing with component{.component}.* - $classMetadata = null; + $path = $this->_identifiers[0]; + $this->_queryComponent = $parserResult->getQueryComponent($path); - for ($i = 0; $i < $l; $i++) { + // We should have a semantical error if the queryComponent does not exists yet + if ($this->_queryComponent === null) { + $this->_parser->semanticalError("Undefined component alias for '{$path}'", $this->_parser->token); + } + + // Initializing ClassMetadata + $classMetadata = $this->_queryComponent['metadata']; + + // Looping through relations + for ($i = 1; $i < $l; $i++) { $relationName = $this->_identifiers[$i]; + $path .= '.' . $relationName; - // We are still checking for relations - if ( $classMetadata !== null && ! $classMetadata->hasRelation($relationName)) { + if ( ! $classMetadata->hasRelation($relationName)) { $className = $classMetadata->getClassName(); - $this->_parser->semanticalError("Relation '{$relationName}' does not exist in component '{$className}'"); - - // Assigning new ClassMetadata - $classMetadata = $classMetadata->getRelation($relationName)->getClassMetadata(); - } elseif ( $classMetadata === null ) { - $queryComponent = $parserResult->getQueryComponent($relationName); - - // We should have a semantical error if the queryComponent does not exists yet - if ($queryComponent === null) { - $this->_parser->semanticalError("Undefined component alias for relation '{$relationName}'"); - } - - // Initializing ClassMetadata - $classMetadata = $queryComponent['metadata']; + $this->_parser->semanticalError( + "Relation '{$relationName}' does not exist in component '{$className}' when trying to get the path '{$path}'", + $this->_parser->token + ); } + + // We inspect for queryComponent of relations, since we are using them + if ( ! $parserResult->hasQueryComponent($path)) { + $this->_parser->semanticalError("Cannot use the path '{$path}' without defining it in FROM.", $this->_parser->token); + } + + // Assigning new queryComponent and classMetadata + $this->_queryComponent = $parserResult->getQueryComponent($path); + + $classMetadata = $this->_queryComponent['metadata']; } } else { // We are dealing with a simple * as our PathExpression. // We need to check if there's only one query component. $queryComponents = $parserResult->getQueryComponents(); - if (count($queryComponents) != 1) { + if (count($queryComponents) != 2) { $this->_parser->semanticalError( "Cannot use * as selector expression for multiple components." ); @@ -94,13 +106,52 @@ class Doctrine_Query_Production_PathExpressionEndingWithAsterisk extends Doctrin // We simplify our life adding the component alias to our AST, // since we have it on hands now. $k = array_keys($queryComponents); - $this->_identifiers[] = $k[0]; + $componentAlias = $k[1]; + + $this->_queryComponent = $queryComponents[$componentAlias]; } } public function buildSql() { - return ''; + // Basic handy variables + $parserResult = $this->_parser->getParserResult(); + + // Retrieving connection + $manager = Doctrine_EntityManager::getManager(); + $conn = $manager->getConnection(); + + // Looking for componentAlias to fetch + $componentAlias = implode('.', $this->_identifiers); + + if (count($this->_identifiers) == 0) { + $queryComponents = $parserResult->getQueryComponents(); + + // Retrieve ClassMetadata + $k = array_keys($queryComponents); + $componentAlias = $k[1]; + } + + // Generating the SQL piece + $fields = $this->_queryComponent['metadata']->getMappedColumns(); + $tableAlias = $parserResult->getTableAliasFromComponentAlias($componentAlias); + $str = ''; + + foreach ($fields as $fieldName => $fieldMap) { + $str .= ($str != '') ? ', ' : ''; + + // DB Field name + $column = $tableAlias . '.' . $this->_queryComponent['metadata']->getColumnName($fieldName); + $column = $conn->quoteIdentifier($column); + + // DB Field alias + $columnAlias = $tableAlias . '__' . $this->_queryComponent['metadata']->getColumnName($fieldName); + $columnAlias = $conn->quoteIdentifier($columnAlias); + + $str .= $column . ' AS ' . $columnAlias; + } + + return $str; } } diff --git a/lib/Doctrine/Query/Production/RangeVariableDeclaration.php b/lib/Doctrine/Query/Production/RangeVariableDeclaration.php index 11a144f16..dd40f9888 100644 --- a/lib/Doctrine/Query/Production/RangeVariableDeclaration.php +++ b/lib/Doctrine/Query/Production/RangeVariableDeclaration.php @@ -129,7 +129,7 @@ class Doctrine_Query_Production_RangeVariableDeclaration extends Doctrine_Query_ 'parent' => null, 'relation' => null, 'map' => null, - 'agg' => null, + 'scalar' => null, ); } catch (Doctrine_Exception $e) { //echo "Tried to load class metadata from '".$componentName."': " . $e->getMessage() . "\n"; @@ -173,7 +173,7 @@ class Doctrine_Query_Production_RangeVariableDeclaration extends Doctrine_Query_ // We loop into others identifier to build query components for ($i = 1, $l = count($this->_identifiers); $i < $l; $i++) { $relationName = $this->_identifiers[$i]; - $path = '.' . $relationName; + $path .= '.' . $relationName; if ($parserResult->hasQueryComponent($path)) { // We already have the query component on hands, get it @@ -211,7 +211,7 @@ class Doctrine_Query_Production_RangeVariableDeclaration extends Doctrine_Query_ 'parent' => $parent, 'relation' => $relation, 'map' => null, - 'agg' => null, + 'scalar' => null, ); $parent = $path; diff --git a/lib/Doctrine/Query/Production/SelectExpression.php b/lib/Doctrine/Query/Production/SelectExpression.php index e94480af8..be88c0cc7 100644 --- a/lib/Doctrine/Query/Production/SelectExpression.php +++ b/lib/Doctrine/Query/Production/SelectExpression.php @@ -38,7 +38,7 @@ class Doctrine_Query_Production_SelectExpression extends Doctrine_Query_Producti protected $_isSubselect; - protected $_identificationVariable; + protected $_fieldIdentificationVariable; private $__columnAliasInSql; @@ -51,12 +51,20 @@ class Doctrine_Query_Production_SelectExpression extends Doctrine_Query_Producti if ($this->_isPathExpressionEndingWithAsterisk()) { $this->_leftExpression = $this->AST('PathExpressionEndingWithAsterisk', $paramHolder); + + $fieldName = implode('.', $this->_leftExpression->getIdentifiers()) . '.*'; } elseif(($this->_isSubselect = $this->_isSubselect()) === true) { $this->_parser->match('('); $this->_leftExpression = $this->AST('Subselect', $paramHolder); $this->_parser->match(')'); + + // [TODO] Any way to make it more fancy for user error? + $fieldName = ''; } else { $this->_leftExpression = $this->AST('Expression', $paramHolder); + + // [TODO] Any way to make it more fancy for user error? + $fieldName = ''; } if ($this->_isNextToken(Doctrine_Query_Token::T_AS)) { @@ -64,17 +72,24 @@ class Doctrine_Query_Production_SelectExpression extends Doctrine_Query_Producti } if ($this->_isNextToken(Doctrine_Query_Token::T_IDENTIFIER)) { - $this->_identificationVariable = $this->AST('IdentificationVariable', $paramHolder); + $paramHolder->set('fieldName', $fieldName); + + // Will return an identifier, with the semantical check already applied + $this->_fieldIdentificationVariable = $this->AST('FieldIdentificationVariable', $paramHolder); + + $paramHolder->remove('fieldName'); } } public function semantical($paramHolder) { + $parserResult = $this->_parser->getParserResult(); + // Here we inspect for duplicate IdentificationVariable, and if the // left expression needs the identification variable. If yes, check // its existance. - if ($this->_leftExpression instanceof Doctrine_Query_Production_PathExpressionEndingWithAsterisk && $this->_identificationVariable !== null) { + if ($this->_leftExpression instanceof Doctrine_Query_Production_PathExpressionEndingWithAsterisk && $this->_fieldIdentificationVariable !== null) { $this->_parser->semanticalError( "Cannot assign an identification variable to a path expression with asterisk (ie. foo.bar.* AS foobaz)." ); @@ -82,34 +97,15 @@ class Doctrine_Query_Production_SelectExpression extends Doctrine_Query_Producti $this->_leftExpression->semantical($paramHolder); - /*if ($this->_identificationVariable !== null) { - if ($this->_leftExpression instanceof Doctrine_Query_Production_PathExpression) { - // We bring the queryComponent from the class instance - // $queryComponent = $this->_leftExpression->getQueryComponent(); - } else { - // We bring the default queryComponent - // $queryComponent = $parserResult->getQueryComponent(null); - } - - $idx = count($queryComponent['scalar']); - $this->__columnAliasInSql .= '__' . $idx; - - $queryComponent['scalar'][$idx] = $this->_identificationVariable; - - //$parserResult->setQueryComponent($componentAlias, $queryComponent); - }*/ - - // We need to add scalar in queryComponent the item alias if identificationvariable is set. - //echo "SelectExpression:\n"; - //echo get_class($this->_leftExpression) . "\n"; - - // The check for duplicate IdentificationVariable was already done + if($this->_fieldIdentificationVariable !== null) { + $this->_fieldIdentificationVariable->semantical($paramHolder); + } } public function buildSql() { - return $this->_leftExpression->buildSql();// . ' AS ' . (($this->_identificationVariable !== null) ? $this->_identificationVariable : ''); + return $this->_leftExpression->buildSql() . $this->_buildColumnAliasInSql(); } @@ -124,4 +120,54 @@ class Doctrine_Query_Production_SelectExpression extends Doctrine_Query_Producti return $token['value'] === '*'; } + + + protected function _buildColumnAliasInSql() + { + // Retrieving parser result + $parserResult = $this->_parser->getParserResult(); + + switch (get_class($this->_leftExpression)) { + case 'Doctrine_Query_Production_PathExpressionEndingWithAsterisk': + return ''; + break; + + case 'Doctrine_Query_Production_PathExpression': + // We bring the queryComponent from the class instance + $queryComponent = $this->_leftExpression->getQueryComponent(); + break; + + default: + // We bring the default queryComponent + $queryComponent = $parserResult->getQueryComponent('dctrn'); + break; + } + + // Retrieving connection + $manager = Doctrine_EntityManager::getManager(); + $conn = $manager->getConnection(); + + $componentAlias = $parserResult->getComponentAlias($queryComponent); + + if ($this->_fieldIdentificationVariable !== null) { + // We need to add scalar map in queryComponent if iidentificationvariable is set. + $idx = count($queryComponent['scalar']); + $queryComponent['scalar'][$idx] = $this->_fieldIdentificationVariable; + $parserResult->setQueryComponent($componentAlias, $queryComponent); + + $columnAlias = $parserResult->getTableAliasFromComponentAlias($componentAlias) . '__' . $idx; + } elseif ($this->_leftExpression instanceof Doctrine_Query_Production_PathExpression) { + // We need to build the column alias based on column name + $columnAlias = $parserResult->getTableAliasFromComponentAlias($componentAlias) + . '__' . $queryComponent['metadata']->getColumnName($this->_leftExpression->getFieldName()); + } else { + // The right thing should be return the index alone... but we need a better solution. + // Possible we can search the index for mapped values and add our item there. + + // [TODO] Find another return value. We cant return 0 here. + $columnAlias = 'idx__' . 0; + } + + return ' AS ' . $conn->quoteIdentifier($columnAlias); + } } diff --git a/lib/Doctrine/Query/Production/VariableDeclaration.php b/lib/Doctrine/Query/Production/VariableDeclaration.php index 0b52a58f1..ebf6ec297 100644 --- a/lib/Doctrine/Query/Production/VariableDeclaration.php +++ b/lib/Doctrine/Query/Production/VariableDeclaration.php @@ -96,7 +96,7 @@ class Doctrine_Query_Production_VariableDeclaration extends Doctrine_Query_Produ 'parent' => null, 'relation' => null, 'map' => null, - 'agg' => null, + 'scalar' => null, ); } catch (Doctrine_Exception $e) { $this->_parser->semanticalError($e->getMessage()); diff --git a/query-language.txt b/query-language.txt index d2075fbb3..ac40a3d12 100644 --- a/query-language.txt +++ b/query-language.txt @@ -40,6 +40,7 @@ UpdateItem = PathExpression "=" (Expression | "NULL") IdentificationVariableDeclaration = RangeVariableDeclaration [IndexBy] {Join [IndexBy]} RangeVariableDeclaration = identifier {"." identifier} [["AS"] IdentificationVariable] VariableDeclaration = identifier [["AS"] IdentificationVariable] +IdentificationVariable = identifier Join = ["LEFT" | "INNER"] "JOIN" RangeVariableDeclaration [("ON" | "WITH") ConditionalExpression] IndexBy = "INDEX" "BY" identifier @@ -59,9 +60,10 @@ Term = Factor {("*" | "/") Factor} Factor = [("+" | "-")] Primary Primary = PathExpression | Atom | "(" Expression ")" | Function | AggregateExpression -SelectExpression = (PathExpressionEndingWithAsterisk | Expression | "(" Subselect ")" ) [["AS"] IdentificationVariable] +SelectExpression = (PathExpressionEndingWithAsterisk | Expression | "(" Subselect ")" ) [["AS"] FieldIdentificationVariable] PathExpression = identifier {"." identifier} PathExpressionEndingWithAsterisk = {identifier "."} "*" +FieldIdentificationVariable = identifier AggregateExpression = ("AVG" | "MAX" | "MIN" | "SUM") "(" ["DISTINCT"] Expression ")" | "COUNT" "(" ["DISTINCT"] (Expression | "*") ")" diff --git a/tests/Orm/Query/IdentifierRecognitionTest.php b/tests/Orm/Query/IdentifierRecognitionTest.php index 368a5eac8..0c0a69c08 100755 --- a/tests/Orm/Query/IdentifierRecognitionTest.php +++ b/tests/Orm/Query/IdentifierRecognitionTest.php @@ -48,7 +48,7 @@ class Orm_Query_IdentifierRecognitionTest extends Doctrine_OrmTestCase $this->assertTrue($decl['metadata'] instanceof Doctrine_ClassMetadata); $this->assertEquals(null, $decl['relation']); $this->assertEquals(null, $decl['parent']); - $this->assertEquals(null, $decl['agg']); + $this->assertEquals(null, $decl['scalar']); $this->assertEquals(null, $decl['map']); } @@ -63,7 +63,7 @@ class Orm_Query_IdentifierRecognitionTest extends Doctrine_OrmTestCase $this->assertTrue($decl['metadata'] instanceof Doctrine_ClassMetadata); $this->assertEquals(null, $decl['relation']); $this->assertEquals(null, $decl['parent']); - $this->assertEquals(null, $decl['agg']); + $this->assertEquals(null, $decl['scalar']); $this->assertEquals('id', $decl['map']); } @@ -78,7 +78,7 @@ class Orm_Query_IdentifierRecognitionTest extends Doctrine_OrmTestCase $this->assertTrue($decl['metadata'] instanceof Doctrine_ClassMetadata); $this->assertEquals(null, $decl['relation']); $this->assertEquals(null, $decl['parent']); - $this->assertEquals(null, $decl['agg']); + $this->assertEquals(null, $decl['scalar']); $this->assertEquals('id', $decl['map']); $decl = $parserResult->getQueryComponent('p'); @@ -86,7 +86,7 @@ class Orm_Query_IdentifierRecognitionTest extends Doctrine_OrmTestCase $this->assertTrue($decl['metadata'] instanceof Doctrine_ClassMetadata); $this->assertTrue($decl['relation'] instanceof Doctrine_Relation); $this->assertEquals('u', $decl['parent']); - $this->assertEquals(null, $decl['agg']); + $this->assertEquals(null, $decl['scalar']); $this->assertEquals(null, $decl['map']); } @@ -102,7 +102,7 @@ class Orm_Query_IdentifierRecognitionTest extends Doctrine_OrmTestCase $this->assertTrue($decl['metadata'] instanceof Doctrine_ClassMetadata); $this->assertEquals(null, $decl['relation']); $this->assertEquals(null, $decl['parent']); - $this->assertEquals(null, $decl['agg']); + $this->assertEquals(null, $decl['scalar']); $this->assertEquals('id', $decl['map']); $decl = $parserResult->getQueryComponent('a'); @@ -110,7 +110,7 @@ class Orm_Query_IdentifierRecognitionTest extends Doctrine_OrmTestCase $this->assertTrue($decl['metadata'] instanceof Doctrine_ClassMetadata); $this->assertTrue($decl['relation'] instanceof Doctrine_Relation); $this->assertEquals('u', $decl['parent']); - $this->assertEquals(null, $decl['agg']); + $this->assertEquals(null, $decl['scalar']); $this->assertEquals(null, $decl['map']); $decl = $parserResult->getQueryComponent('pn'); @@ -118,7 +118,7 @@ class Orm_Query_IdentifierRecognitionTest extends Doctrine_OrmTestCase $this->assertTrue($decl['metadata'] instanceof Doctrine_ClassMetadata); $this->assertTrue($decl['relation'] instanceof Doctrine_Relation); $this->assertEquals('u', $decl['parent']); - $this->assertEquals(null, $decl['agg']); + $this->assertEquals(null, $decl['scalar']); $this->assertEquals('phonenumber', $decl['map']); } } diff --git a/tests/Orm/Query/LanguageRecognitionTest.php b/tests/Orm/Query/LanguageRecognitionTest.php index 58b47ae37..1df701892 100755 --- a/tests/Orm/Query/LanguageRecognitionTest.php +++ b/tests/Orm/Query/LanguageRecognitionTest.php @@ -336,7 +336,7 @@ class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase public function testIndexBySupportsJoins2() { - $this->assertValidDql('SELECT u.*, u.phonenumbers.* FROM CmsUser u INDEX BY id LEFT JOIN u.phonenumbers p INDEX BY phonenumber'); + $this->assertValidDql('SELECT u.*, p.* FROM CmsUser u INDEX BY id LEFT JOIN u.phonenumbers p INDEX BY phonenumber'); } public function testBetweenExpressionSupported() diff --git a/tests/Orm/Query/SelectSqlGenerationTest.php b/tests/Orm/Query/SelectSqlGenerationTest.php index 095233a6f..76c966cbf 100755 --- a/tests/Orm/Query/SelectSqlGenerationTest.php +++ b/tests/Orm/Query/SelectSqlGenerationTest.php @@ -46,9 +46,9 @@ class Orm_Query_SelectSqlGenerationTest extends Doctrine_OrmTestCase $this->assertEquals('SELECT cu.id AS cu__id FROM cms_user cu WHERE 1 = 1', $q->getSql()); $q->free(); - //$q->setDql('SELECT u.* FROM CmsUser u'); - //$this->assertEquals('DELETE FROM cms_user cu WHERE 1 = 1', $q->getSql()); - //$q->free(); + $q->setDql('SELECT u.* FROM CmsUser u'); + $this->assertEquals('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', $q->getSql()); + $q->free(); } /*