Skip to content

Commit

Permalink
add missed array type cast functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pfilsx committed Mar 23, 2023
1 parent f1eef5b commit b037225
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/Functions-and-Operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@
| PLAINTO_TSQUERY() | PLAINTO_TSQUERY | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\PlainToTsQuery](../src/ORM/Query/AST/Functions/PlainToTsQuery.php) |
| STRING_AGG() | STRING_AGG | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\StringAgg](../src/ORM/Query/AST/Functions/StringAgg.php) |
| ARRAY[] | ARRAY | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\ToArray](../src/ORM/Query/AST/Functions/ToArray.php) |
| BIGINT[] | BIGINT_ARRAY | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\ToBigIntArray](../src/ORM/Query/AST/Functions/ToBigIntArray.php) |
| BOOLEAN[] | BOOLEAN_ARRAY | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\ToBooleanArray](../src/ORM/Query/AST/Functions/ToBooleanArray.php) |
| INT[] | INT_ARRAY | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\ToIntArray](../src/ORM/Query/AST/Functions/ToIntArray.php) |
| TO_JSON() | TO_JSON | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\ToJson](../src/ORM/Query/AST/Functions/ToJson.php) |
| TO_JSONB() | TO_JSONB | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\ToJsonb](../src/ORM/Query/AST/Functions/ToJsonb.php) |
| SMALLINT[] | SMALLINT_ARRAY | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\ToSmallIntArray](../src/ORM/Query/AST/Functions/ToSmallIntArray.php) |
| TEXT[] | TEXT_ARRAY | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\ToTextArray](../src/ORM/Query/AST/Functions/ToTextArray.php) |
| TO_TSQUERY() | TO_TSQUERY | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\ToTsQuery](../src/ORM/Query/AST/Functions/ToTsQuery.php) |
| TO_TSVECTOR() | TO_TSVECTOR | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\ToTsVector](../src/ORM/Query/AST/Functions/ToTsVector.php) |
| TS_HEADLINE() | TS_HEADLINE | [Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions\TsHeadline](../src/ORM/Query/AST/Functions/TsHeadline.php) |
Expand Down
23 changes: 23 additions & 0 deletions src/ORM/Query/AST/Functions/ToBigIntArray.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions;

use Doctrine\ORM\Query\SqlWalker;

/**
* Implementation of PostgreSql ARRAY[] type for bigint.
*
* @see https://www.postgresql.org/docs/current/arrays.html
*
* @example BIGINT_ARRAY('1', '2', '3')
* @example BIGINT_ARRAY(:input)
*/
class ToBigIntArray extends ToArray
{
public function getSql(SqlWalker $sqlWalker): string
{
return parent::getSql($sqlWalker) . '::bigint[]';
}
}
23 changes: 23 additions & 0 deletions src/ORM/Query/AST/Functions/ToBooleanArray.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions;

use Doctrine\ORM\Query\SqlWalker;

/**
* Implementation of PostgreSql ARRAY[] type for booleans.
*
* @see https://www.postgresql.org/docs/current/arrays.html
*
* @example BOOLEAN_ARRAY(1, 0, 1)
* @example BOOLEAN_ARRAY(:input)
*/
class ToBooleanArray extends ToArray
{
public function getSql(SqlWalker $sqlWalker): string
{
return parent::getSql($sqlWalker) . '::boolean[]';
}
}
23 changes: 23 additions & 0 deletions src/ORM/Query/AST/Functions/ToIntArray.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions;

use Doctrine\ORM\Query\SqlWalker;

/**
* Implementation of PostgreSql ARRAY[] type for integers.
*
* @see https://www.postgresql.org/docs/current/arrays.html
*
* @example INT_ARRAY('1', '2', '3')
* @example INT_ARRAY(:input)
*/
class ToIntArray extends ToArray
{
public function getSql(SqlWalker $sqlWalker): string
{
return parent::getSql($sqlWalker) . '::integer[]';
}
}
23 changes: 23 additions & 0 deletions src/ORM/Query/AST/Functions/ToSmallIntArray.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions;

use Doctrine\ORM\Query\SqlWalker;

/**
* Implementation of PostgreSql ARRAY[] type for smallint.
*
* @see https://www.postgresql.org/docs/current/arrays.html
*
* @example SMALLINT_ARRAY('1', '2', '3')
* @example SMALLINT_ARRAY(:input)
*/
class ToSmallIntArray extends ToArray
{
public function getSql(SqlWalker $sqlWalker): string
{
return parent::getSql($sqlWalker) . '::smallint[]';
}
}
23 changes: 23 additions & 0 deletions src/ORM/Query/AST/Functions/ToTextArray.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions;

use Doctrine\ORM\Query\SqlWalker;

/**
* Implementation of PostgreSql ARRAY[] type for texts.
*
* @see https://www.postgresql.org/docs/current/arrays.html
*
* @example TEXT_ARRAY(1, 2, 3)
* @example TEXT_ARRAY(:input)
*/
class ToTextArray extends ToArray
{
public function getSql(SqlWalker $sqlWalker): string
{
return parent::getSql($sqlWalker) . '::text[]';
}
}

0 comments on commit b037225

Please sign in to comment.