Skip to content

Commit b037225

Browse files
committed
add missed array type cast functions
1 parent f1eef5b commit b037225

File tree

6 files changed

+120
-0
lines changed

6 files changed

+120
-0
lines changed

docs/Functions-and-Operators.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@
2323
| PLAINTO_TSQUERY() | PLAINTO_TSQUERY | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\PlainToTsQuery](../src/ORM/Query/AST/Functions/PlainToTsQuery.php) |
2424
| STRING_AGG() | STRING_AGG | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\StringAgg](../src/ORM/Query/AST/Functions/StringAgg.php) |
2525
| ARRAY[] | ARRAY | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\ToArray](../src/ORM/Query/AST/Functions/ToArray.php) |
26+
| BIGINT[] | BIGINT_ARRAY | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\ToBigIntArray](../src/ORM/Query/AST/Functions/ToBigIntArray.php) |
27+
| BOOLEAN[] | BOOLEAN_ARRAY | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\ToBooleanArray](../src/ORM/Query/AST/Functions/ToBooleanArray.php) |
28+
| INT[] | INT_ARRAY | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\ToIntArray](../src/ORM/Query/AST/Functions/ToIntArray.php) |
2629
| TO_JSON() | TO_JSON | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\ToJson](../src/ORM/Query/AST/Functions/ToJson.php) |
2730
| TO_JSONB() | TO_JSONB | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\ToJsonb](../src/ORM/Query/AST/Functions/ToJsonb.php) |
31+
| SMALLINT[] | SMALLINT_ARRAY | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\ToSmallIntArray](../src/ORM/Query/AST/Functions/ToSmallIntArray.php) |
32+
| TEXT[] | TEXT_ARRAY | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\ToTextArray](../src/ORM/Query/AST/Functions/ToTextArray.php) |
2833
| TO_TSQUERY() | TO_TSQUERY | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\ToTsQuery](../src/ORM/Query/AST/Functions/ToTsQuery.php) |
2934
| TO_TSVECTOR() | TO_TSVECTOR | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\ToTsVector](../src/ORM/Query/AST/Functions/ToTsVector.php) |
3035
| TS_HEADLINE() | TS_HEADLINE | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\TsHeadline](../src/ORM/Query/AST/Functions/TsHeadline.php) |
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions;
6+
7+
use Doctrine\ORM\Query\SqlWalker;
8+
9+
/**
10+
* Implementation of PostgreSql ARRAY[] type for bigint.
11+
*
12+
* @see https://www.postgresql.org/docs/current/arrays.html
13+
*
14+
* @example BIGINT_ARRAY('1', '2', '3')
15+
* @example BIGINT_ARRAY(:input)
16+
*/
17+
class ToBigIntArray extends ToArray
18+
{
19+
public function getSql(SqlWalker $sqlWalker): string
20+
{
21+
return parent::getSql($sqlWalker) . '::bigint[]';
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions;
6+
7+
use Doctrine\ORM\Query\SqlWalker;
8+
9+
/**
10+
* Implementation of PostgreSql ARRAY[] type for booleans.
11+
*
12+
* @see https://www.postgresql.org/docs/current/arrays.html
13+
*
14+
* @example BOOLEAN_ARRAY(1, 0, 1)
15+
* @example BOOLEAN_ARRAY(:input)
16+
*/
17+
class ToBooleanArray extends ToArray
18+
{
19+
public function getSql(SqlWalker $sqlWalker): string
20+
{
21+
return parent::getSql($sqlWalker) . '::boolean[]';
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions;
6+
7+
use Doctrine\ORM\Query\SqlWalker;
8+
9+
/**
10+
* Implementation of PostgreSql ARRAY[] type for integers.
11+
*
12+
* @see https://www.postgresql.org/docs/current/arrays.html
13+
*
14+
* @example INT_ARRAY('1', '2', '3')
15+
* @example INT_ARRAY(:input)
16+
*/
17+
class ToIntArray extends ToArray
18+
{
19+
public function getSql(SqlWalker $sqlWalker): string
20+
{
21+
return parent::getSql($sqlWalker) . '::integer[]';
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions;
6+
7+
use Doctrine\ORM\Query\SqlWalker;
8+
9+
/**
10+
* Implementation of PostgreSql ARRAY[] type for smallint.
11+
*
12+
* @see https://www.postgresql.org/docs/current/arrays.html
13+
*
14+
* @example SMALLINT_ARRAY('1', '2', '3')
15+
* @example SMALLINT_ARRAY(:input)
16+
*/
17+
class ToSmallIntArray extends ToArray
18+
{
19+
public function getSql(SqlWalker $sqlWalker): string
20+
{
21+
return parent::getSql($sqlWalker) . '::smallint[]';
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions;
6+
7+
use Doctrine\ORM\Query\SqlWalker;
8+
9+
/**
10+
* Implementation of PostgreSql ARRAY[] type for texts.
11+
*
12+
* @see https://www.postgresql.org/docs/current/arrays.html
13+
*
14+
* @example TEXT_ARRAY(1, 2, 3)
15+
* @example TEXT_ARRAY(:input)
16+
*/
17+
class ToTextArray extends ToArray
18+
{
19+
public function getSql(SqlWalker $sqlWalker): string
20+
{
21+
return parent::getSql($sqlWalker) . '::text[]';
22+
}
23+
}

0 commit comments

Comments
 (0)