Implemented support for internal exception showing DQL that contains syntax or semantical error.
This commit is contained in:
parent
93fcb74f9a
commit
d05ad996c4
@ -25,7 +25,7 @@ use Doctrine\ORM\Query\Parser;
|
||||
use Doctrine\ORM\Query\QueryException;
|
||||
|
||||
/**
|
||||
* "DATE_ADD(date1, interval, unit)"
|
||||
* "DATE_ADD" "(" ArithmeticPrimary "," ArithmeticPrimary "," StringPrimary ")"
|
||||
*
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link www.doctrine-project.org
|
||||
|
@ -24,7 +24,7 @@ use Doctrine\ORM\Query\SqlWalker;
|
||||
use Doctrine\ORM\Query\Parser;
|
||||
|
||||
/**
|
||||
* "DATE_DIFF(date1, date2)"
|
||||
* "DATE_DIFF" "(" ArithmeticPrimary "," ArithmeticPrimary ")"
|
||||
*
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link www.doctrine-project.org
|
||||
|
@ -377,7 +377,7 @@ class Parser
|
||||
$message .= ($expected !== '') ? "Expected {$expected}, got " : 'Unexpected ';
|
||||
$message .= ($this->_lexer->lookahead === null) ? 'end of string.' : "'{$token['value']}'";
|
||||
|
||||
throw QueryException::syntaxError($message);
|
||||
throw QueryException::syntaxError($message, QueryException::dqlError($this->_query->getDQL()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -410,7 +410,7 @@ class Parser
|
||||
// Building informative message
|
||||
$message = 'line 0, col ' . $tokenPos . " near '" . $tokenStr . "': Error: " . $message;
|
||||
|
||||
throw QueryException::semanticalError($message);
|
||||
throw QueryException::semanticalError($message, QueryException::dqlError($this->_query->getDQL()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1381,7 +1381,7 @@ class Parser
|
||||
*
|
||||
* NewValue ::= SimpleArithmeticExpression | "NULL"
|
||||
*
|
||||
* SimpleArithmeticExpression covers all *Primary grammar rules and also SimplEntityExpression
|
||||
* SimpleArithmeticExpression covers all *Primary grammar rules and also SimpleEntityExpression
|
||||
*/
|
||||
public function NewValue()
|
||||
{
|
||||
@ -2483,7 +2483,8 @@ class Parser
|
||||
/**
|
||||
* ArithmeticPrimary ::= SingleValuedPathExpression | Literal | "(" SimpleArithmeticExpression ")"
|
||||
* | FunctionsReturningNumerics | AggregateExpression | FunctionsReturningStrings
|
||||
* | FunctionsReturningDatetime | IdentificationVariable | ResultVariable | CaseExpression
|
||||
* | FunctionsReturningDatetime | IdentificationVariable | ResultVariable
|
||||
* | InputParameter | CaseExpression
|
||||
*/
|
||||
public function ArithmeticPrimary()
|
||||
{
|
||||
|
@ -37,14 +37,19 @@ use Doctrine\ORM\Query\AST\PathExpression;
|
||||
*/
|
||||
class QueryException extends \Doctrine\ORM\ORMException
|
||||
{
|
||||
public static function syntaxError($message)
|
||||
public static function dqlError($dql)
|
||||
{
|
||||
return new self('[Syntax Error] ' . $message);
|
||||
return new self($dql);
|
||||
}
|
||||
|
||||
public static function semanticalError($message)
|
||||
public static function syntaxError($message, $previous = null)
|
||||
{
|
||||
return new self('[Semantical Error] ' . $message);
|
||||
return new self('[Syntax Error] ' . $message, 0, $previous);
|
||||
}
|
||||
|
||||
public static function semanticalError($message, $previous = null)
|
||||
{
|
||||
return new self('[Semantical Error] ' . $message, 0, $previous);
|
||||
}
|
||||
|
||||
public static function invalidLockMode()
|
||||
|
Loading…
x
Reference in New Issue
Block a user