Comments (2)
Looking at this package I've noticed too that the ARRAY
function doesn't work correctly, it seems to accept only a single argument, rather than the variable number of arguments of the pg function.
My understanding is that the DQL ARRAY( 'foo', 'bar', 'baz' )
should produce the SQL ARRAY['foo','bar','baz']
, but instead throws a parser error as it's expecting only a single argument?
from postgresql-for-doctrine.
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;
}
}
from postgresql-for-doctrine.
Related Issues (20)
- heavy composer package with uneeded files HOT 2
- How to use TO_JSON with JSON_GET_FIELD_AS_TEXT HOT 1
- jsonb_build_object support? HOT 1
- Postgres 14-specific JSON syntax HOT 1
- array_agg doesn't support ORDER BY HOT 1
- float[] type
- Jsonb::convertToPHPValue(): Return value must be of type array|string|int|float|null, bool returned HOT 2
- symfony / doctrine configuration help HOT 1
- getResults() returns arrays instead of objects HOT 1
- ? and ?| operators HOT 4
- `ANY` should accept `text[]` field, currently throw a `Expected Doctrine\ORM\Query\Lexer::T_SELECT` HOT 2
- Dependency Dashboard
- Cant install 2.1.1 version HOT 1
- Error with symfony and dql ilke function HOT 1
- Error with UNACCENT HOT 2
- Jsonb type limited convert HOT 4
- Cannot use object of type Doctrine\Common\Lexer\Token as array HOT 1
- Add support for DBAL v4 HOT 3
- InArray use ANY instead of ANY_OF HOT 2
- Wanted to add your package in PHP 8.0.12 project, but PHP version requirement is not met HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from postgresql-for-doctrine.