Commit 0eebb11d authored by Niklas de Vries's avatar Niklas de Vries

Added AndAnd (&&) operator

parent d484932c
<?php
/*
* This file is part of the CWD Data Doctrine ORM Bundle
*
* (c) cwd.at GmbH <office@cwd.at>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cwd\DataDoctrineORMBundle\Func\Postgresql\String;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
/**
* AndAnd ::= "AND_AND" "(" LeftHandSide "," RightHandSide ")".
*
* This will be converted to: "( LeftHandSide && RightHandSide )"
*/
class AndAnd extends FunctionNode
{
public $leftHandSide = null;
public $rightHandSide = null;
/**
* {@inheritdoc}
*/
public function parse(Parser $parser)
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->leftHandSide = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_COMMA);
$this->rightHandSide = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
/**
* {@inheritdoc}
*/
public function getSql(SqlWalker $sqlWalker)
{
// We use a workaround to allow this statement in a WHERE. Doctrine relies on the existence of an ComparisonOperator
return '('.
$this->leftHandSide->dispatch($sqlWalker).' && '.
$this->rightHandSide->dispatch($sqlWalker).
')';
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment