diff --git a/lib/Doctrine/ORM/Query/AST/PathExpression.php b/lib/Doctrine/ORM/Query/AST/PathExpression.php index 996d35c27..4f8d0e277 100644 --- a/lib/Doctrine/ORM/Query/AST/PathExpression.php +++ b/lib/Doctrine/ORM/Query/AST/PathExpression.php @@ -41,7 +41,6 @@ namespace Doctrine\ORM\Query\AST; */ class PathExpression extends Node { - const TYPE_IDENTIFICATION_VARIABLE = 1; const TYPE_COLLECTION_VALUED_ASSOCIATION = 2; const TYPE_SINGLE_VALUED_ASSOCIATION = 4; const TYPE_STATE_FIELD = 8; diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index 6f9e73c26..5d9766262 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -557,40 +557,44 @@ class Parser { foreach ($this->_deferredPathExpressions as $deferredItem) { $pathExpression = $deferredItem['expression']; - $parts = $pathExpression->parts; - $numParts = count($parts); $qComp = $this->_queryComponents[$pathExpression->identificationVariable]; + $numParts = count($pathExpression->parts); + if ($numParts == 0) { + $pathExpression->parts = array($qComp['metadata']->identifier[0]); + $numParts++; + } + + $parts = $pathExpression->parts; $aliasIdentificationVariable = $pathExpression->identificationVariable; $parentField = $pathExpression->identificationVariable; $class = $qComp['metadata']; - $fieldType = ($pathExpression->expectedType == AST\PathExpression::TYPE_IDENTIFICATION_VARIABLE) - ? AST\PathExpression::TYPE_IDENTIFICATION_VARIABLE : null; + $fieldType = null; $curIndex = 0; foreach ($parts as $field) { // Check if it is not in a state field if ($fieldType & AST\PathExpression::TYPE_STATE_FIELD) { $this->semanticalError( - 'Cannot navigate through state field named ' . $field . ' on ' . $parentField, - $deferredItem['token'] + 'Cannot navigate through state field named ' . $field . ' on ' . $parentField, + $deferredItem['token'] ); } // Check if it is not a collection field if ($fieldType & AST\PathExpression::TYPE_COLLECTION_VALUED_ASSOCIATION) { $this->semanticalError( - 'Cannot navigate through collection field named ' . $field . ' on ' . $parentField, - $deferredItem['token'] + 'Cannot navigate through collection field named ' . $field . ' on ' . $parentField, + $deferredItem['token'] ); } // Check if field or association exists if ( ! isset($class->associationMappings[$field]) && ! isset($class->fieldMappings[$field])) { $this->semanticalError( - 'Class ' . $class->name . ' has no field or association named ' . $field, - $deferredItem['token'] + 'Class ' . $class->name . ' has no field or association named ' . $field, + $deferredItem['token'] ); } @@ -650,11 +654,6 @@ class Parser // We need to recognize which was expected type(s) $expectedStringTypes = array(); - // Validate state field type - if ($expectedType & AST\PathExpression::TYPE_IDENTIFICATION_VARIABLE) { - $expectedStringTypes[] = 'IdentificationVariable'; - } - // Validate state field type if ($expectedType & AST\PathExpression::TYPE_STATE_FIELD) { $expectedStringTypes[] = 'StateFieldPathExpression'; @@ -2174,7 +2173,7 @@ class Parser return $this->SingleValuedPathExpression(); } - return $this->PathExpression(AST\PathExpression::TYPE_IDENTIFICATION_VARIABLE); + return $this->SimpleStateFieldPathExpression(); case Lexer::T_INPUT_PARAMETER: return $this->InputParameter(); diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 25263dac5..f624798fd 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -446,17 +446,6 @@ class SqlWalker implements TreeWalker $sql = ''; switch ($pathExpr->type) { - case AST\PathExpression::TYPE_IDENTIFICATION_VARIABLE: - $dqlAlias = $pathExpr->identificationVariable; - $class = $this->_queryComponents[$dqlAlias]['metadata']; - - if ($this->_useSqlTableAliases) { - $sql .= $this->walkIdentificationVariable($dqlAlias) . '.'; - } - - $sql .= $class->getQuotedColumnName($class->identifier[0], $this->_platform); - break; - case AST\PathExpression::TYPE_STATE_FIELD: $parts = $pathExpr->parts; $fieldName = array_pop($parts);