-
-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ARRAY with multiple arguments #95
Comments
Looking at this package I've noticed too that the My understanding is that the DQL |
Here a rewrite that permit to have array with multiple arg <?php
namespace App\Dql;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\AST\Node;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
/**
* array with multiple element
* ex: OVERLAPS(ARRAY('anru', 'tva'), l.fiscalites) = true
*/
class Arr extends FunctionNode
{
private ?Node $field = null;
private array $values = [];
public function __construct()
{
parent::__construct("ARRAY");
}
public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->field = $parser->ArithmeticPrimary();
$lexer = $parser->getLexer();
while (count($this->values) < 1 || $lexer->lookahead['type'] !== Lexer::T_CLOSE_PARENTHESIS) {
$parser->match(Lexer::T_COMMA);
$this->values[] = $parser->ArithmeticPrimary(); // renvoi le node
}
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
public function getSql(SqlWalker $sqlWalker): string
{
$query = 'ARRAY[';
$query .= $this->field->dispatch($sqlWalker);
$query .= ', ';
foreach ($this->values as $i => $iValue) {
if ($i > 0) {
$query .= ', ';
}
$query .= $iValue->dispatch($sqlWalker);
}
$query .= ']';
return $query;
}
} |
I'd like to use this kind of postgres code
Array_to_string(ARRAY['a', 'b', 'c'], ';')
which givesa;b;c
but this does not parse in dql :
The text was updated successfully, but these errors were encountered: