Details
Description
When you go to compare Bit Values in MySQL Database you can do thiy by "&" or "|" If you do this with Doctrine 2 you got an exception like following:
Message: [Syntax Error] line 0, col 161: Error: Expected =, <, <=, <>, >, >=, != got '&'
So i fixed this problem for me:
Doctrine\ORM\Query\Parser:
Line 2633
/**
* ComparisonOperator ::= "=" | "<" | "<=" | "<>" | ">" | ">=" | "!=" | "&" | "|"
*
* @return string
*/
public function ComparisonOperator()
{
switch ($this->_lexer->lookahead['value']) {
case '=':
$this->match(Lexer::T_EQUALS);
return '=';
case '<':
$this->match(Lexer::T_LOWER_THAN);
$operator = '<';
if ($this->_lexer->isNextToken(Lexer::T_EQUALS)) {
$this->match(Lexer::T_EQUALS);
$operator .= '=';
} else if ($this->_lexer->isNextToken(Lexer::T_GREATER_THAN)) {
$this->match(Lexer::T_GREATER_THAN);
$operator .= '>';
}
return $operator;
case '>':
$this->match(Lexer::T_GREATER_THAN);
$operator = '>';
if ($this->_lexer->isNextToken(Lexer::T_EQUALS)) {
$this->match(Lexer::T_EQUALS);
$operator .= '=';
}
return $operator;
case '!':
$this->match(Lexer::T_NEGATE);
$this->match(Lexer::T_EQUALS);
return '<>';
/* Changes by SR-RM to make Bit Oprations available */
case '&':
$this->match(LEXER::T_BIT_AND);
return '&';
case '|':
$this->match(LEXER::T_BIT_OR);
return '|';
/* Changes by SR-RM End */
default:
$this->syntaxError('=, <, <=, <>, >, >=, !=, &, |');
}
}
Doctrine\ORM\Query\Lexer:
Line 53
/* Changes SR-RM to make Bit Oprations available */ const T_BIT_AND = 30; const T_BIT_OR = 31; /* Changes by SR-RM End */
Line 193
/* Changes SR-RM to make Bit Oprations available */ case '&': return self::T_BIT_AND; case '|': return self::T_BIT_OR; /* Changes by SR-RM End */
So, maybe you gonna ad this in next Release ![]()
Thanks or your good Job
This issue is referenced in Github Pull-Request GH-230
https://github.com/doctrine/doctrine2/pull/230