[2.0] Fixed issue with DQL that was not considering input parameter 10. Also added support to retrieve the generated AST.
This commit is contained in:
parent
29e5141280
commit
34cbb8af24
3 changed files with 43 additions and 16 deletions
|
@ -165,6 +165,19 @@ final class Query extends AbstractQuery
|
|||
return $this->_parse()->getSqlExecutor()->getSqlStatements();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the correspondent AST for this Query.
|
||||
*
|
||||
* @return \Doctrine\ORM\Query\AST\SelectStatement |
|
||||
* \Doctrine\ORM\Query\AST\UpdateStatement |
|
||||
* \Doctrine\ORM\Query\AST\DeleteStatement
|
||||
*/
|
||||
public function getAST()
|
||||
{
|
||||
$parser = new Parser($this);
|
||||
return $parser->getAST();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the DQL query, if necessary, and stores the parser result.
|
||||
*
|
||||
|
|
|
@ -126,7 +126,7 @@ class Lexer extends \Doctrine\Common\Lexer
|
|||
'[a-z_][a-z0-9_\:\\\]*[a-z0-9_]{1}',
|
||||
'(?:[0-9]+(?:[,\.][0-9]+)*)(?:e[+-]?[0-9]+)?',
|
||||
"'(?:[^']|'')*'",
|
||||
'\?[1-9]+|:[a-z][a-z0-9_]+'
|
||||
'\?[1-9][0-9]*|:[a-z][a-z0-9_]+'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -193,6 +193,34 @@ class Parser
|
|||
return $this->_em;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse and build AST for the given Query.
|
||||
*
|
||||
* @return \Doctrine\ORM\Query\AST\SelectStatement |
|
||||
* \Doctrine\ORM\Query\AST\UpdateStatement |
|
||||
* \Doctrine\ORM\Query\AST\DeleteStatement
|
||||
*/
|
||||
public function getAST()
|
||||
{
|
||||
// Parse & build AST
|
||||
$AST = $this->QueryLanguage();
|
||||
|
||||
// Process any deferred validations of some nodes in the AST.
|
||||
// This also allows post-processing of the AST for modification purposes.
|
||||
$this->_processDeferredIdentificationVariables();
|
||||
if ($this->_deferredPartialObjectExpressions) {
|
||||
$this->_processDeferredPartialObjectExpressions();
|
||||
}
|
||||
if ($this->_deferredPathExpressions) {
|
||||
$this->_processDeferredPathExpressions($AST);
|
||||
}
|
||||
if ($this->_deferredResultVariables) {
|
||||
$this->_processDeferredResultVariables();
|
||||
}
|
||||
|
||||
return $AST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to match the given token with the current lookahead token.
|
||||
*
|
||||
|
@ -239,21 +267,7 @@ class Parser
|
|||
*/
|
||||
public function parse()
|
||||
{
|
||||
// Parse & build AST
|
||||
$AST = $this->QueryLanguage();
|
||||
|
||||
// Process any deferred validations of some nodes in the AST.
|
||||
// This also allows post-processing of the AST for modification purposes.
|
||||
$this->_processDeferredIdentificationVariables();
|
||||
if ($this->_deferredPartialObjectExpressions) {
|
||||
$this->_processDeferredPartialObjectExpressions();
|
||||
}
|
||||
if ($this->_deferredPathExpressions) {
|
||||
$this->_processDeferredPathExpressions($AST);
|
||||
}
|
||||
if ($this->_deferredResultVariables) {
|
||||
$this->_processDeferredResultVariables();
|
||||
}
|
||||
$AST = $this->getAST();
|
||||
|
||||
if ($customWalkers = $this->_query->getHint(Query::HINT_CUSTOM_TREE_WALKERS)) {
|
||||
$this->_customTreeWalkers = $customWalkers;
|
||||
|
|
Loading…
Add table
Reference in a new issue