-
Notifications
You must be signed in to change notification settings - Fork 0
/
ToArray.php
37 lines (31 loc) · 839 Bytes
/
ToArray.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
declare(strict_types=1);
namespace Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions;
use Doctrine\ORM\Query\AST\Node;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\ArrayExpression;
/**
* Implementation of PostgreSql ARRAY[] type.
*
* @see https://www.postgresql.org/docs/current/arrays.html
*
* @example ARRAY(1,2,3)
* @example ARRAY('test')
* @example ARRAY(:input)
*/
class ToArray extends AbstractSingleNodeFunction
{
protected function getFunctionName(): string
{
return 'ARRAY';
}
protected function parseField(Parser $parser): Node
{
return ArrayExpression::parse($parser);
}
public function getSql(SqlWalker $sqlWalker): string
{
return "ARRAY[{$this->field->dispatch($sqlWalker)}]";
}
}