[2.0] Fixed wrong DQL error message. More improvements in DQL parser
This commit is contained in:
parent
55651ec902
commit
3bc4042a63
@ -656,11 +656,12 @@ class Parser
|
||||
$fieldIdentificationVariable = $this->_lexer->token['value'];
|
||||
}
|
||||
} else {
|
||||
// Deny hydration of partial objects if doctrine.forcePartialLoad query hint not defined
|
||||
if (
|
||||
$this->_query->getHydrationMode() == Query::HYDRATE_OBJECT &&
|
||||
! $this->_em->getConfiguration()->getAllowPartialObjects()
|
||||
) {
|
||||
$this->semanticalError('Cannot select partial object when using object hydration');
|
||||
throw DoctrineException::partialObjectsAreDangerous();
|
||||
}
|
||||
|
||||
$expression = $this->StateFieldPathExpression();
|
||||
@ -912,6 +913,7 @@ class Parser
|
||||
public function SingleValuedAssociationPathExpression()
|
||||
{
|
||||
$pathExpr = $this->PathExpression(AST\PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION);
|
||||
|
||||
if ( ! empty($this->_deferredPathExpressionStacks)) {
|
||||
$exprStack = array_pop($this->_deferredPathExpressionStacks);
|
||||
$exprStack[] = $pathExpr;
|
||||
@ -1035,38 +1037,52 @@ class Parser
|
||||
*
|
||||
* PathExpression ::= IdentificationVariable "." {identifier "."}* identifier
|
||||
*
|
||||
* @todo Refactor. We should never use break in a loop! This should use a do { ... } while (...) instead
|
||||
* @return PathExpression
|
||||
*/
|
||||
public function PathExpression($type)
|
||||
{
|
||||
$this->match(Lexer::T_IDENTIFIER);
|
||||
$identificationVariable = $this->_lexer->token['value'];
|
||||
$this->match('.');
|
||||
|
||||
$parts = array();
|
||||
|
||||
while ($this->_lexer->isNextToken(Lexer::T_IDENTIFIER)) {
|
||||
$this->match(Lexer::T_IDENTIFIER);
|
||||
$parts[] = $this->_lexer->token['value'];
|
||||
|
||||
if ($this->_lexer->isNextToken('.')) {
|
||||
do {
|
||||
$this->match('.');
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->match(Lexer::T_IDENTIFIER);
|
||||
|
||||
$parts[] = $this->_lexer->token['value'];
|
||||
} while ($this->_lexer->isNextToken('.'));
|
||||
|
||||
return new AST\PathExpression($type, $identificationVariable, $parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* EntityExpression ::= SingleValuedAssociationPathExpression | SimpleEntityExpression
|
||||
* SimpleEntityExpression ::= IdentificationVariable | InputParameter
|
||||
*/
|
||||
public function EntityExpression()
|
||||
{
|
||||
$glimpse = $this->_lexer->glimpse();
|
||||
|
||||
if ($this->_lexer->isNextToken(Lexer::T_IDENTIFIER) && $glimpse['value'] === '.') {
|
||||
return $this->SingleValuedAssociationPathExpression();
|
||||
}
|
||||
|
||||
return $this->SimpleEntityExpression();
|
||||
}
|
||||
|
||||
/**
|
||||
* SimpleEntityExpression ::= IdentificationVariable | InputParameter
|
||||
*/
|
||||
public function SimpleEntityExpression()
|
||||
{
|
||||
if ($this->_lexer->isNextToken(Lexer::T_INPUT_PARAMETER)) {
|
||||
$this->match(Lexer::T_INPUT_PARAMETER);
|
||||
return new AST\InputParameter($this->_lexer->token['value']);
|
||||
}
|
||||
|
||||
$this->match(Lexer::T_IDENTIFIER);
|
||||
|
||||
return $this->_lexer->token['value'];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1390,15 +1406,12 @@ class Parser
|
||||
* SimpleEntityExpression ::= IdentificationVariable | InputParameter
|
||||
*
|
||||
* @return AST\CollectionMemberExpression
|
||||
* @todo Support SingleValuedAssociationPathExpression and IdentificationVariable
|
||||
*/
|
||||
public function CollectionMemberExpression()
|
||||
{
|
||||
$isNot = false;
|
||||
|
||||
if ($this->_lexer->lookahead['type'] == Lexer::T_INPUT_PARAMETER) {
|
||||
$this->match($this->_lexer->lookahead['value']);
|
||||
$entityExpr = new AST\InputParameter($this->_lexer->token['value']);
|
||||
$entityExpr = $this->EntityExpression();
|
||||
|
||||
if ($this->_lexer->isNextToken(Lexer::T_NOT)) {
|
||||
$isNot = true;
|
||||
@ -1411,12 +1424,9 @@ class Parser
|
||||
$this->match(Lexer::T_OF);
|
||||
}
|
||||
|
||||
$collValuedPathExpr = $this->CollectionValuedPathExpression();
|
||||
} else {
|
||||
throw QueryException::notImplemented();
|
||||
}
|
||||
|
||||
return new AST\CollectionMemberExpression($entityExpr, $collValuedPathExpr, $isNot);
|
||||
return new AST\CollectionMemberExpression(
|
||||
$entityExpr, $this->CollectionValuedPathExpression(), $isNot
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user