forked from martin-georgiev/postgresql-for-doctrine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TO_TSVECTOR, TO_TSQUERY, TO_JSON and TO_JSONB accept more varied argu…
…ments (martin-georgiev#48)
- Loading branch information
1 parent
d5c6b84
commit b8acbb0
Showing
6 changed files
with
86 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToJsonTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MartinGeorgiev\Tests\Doctrine\ORM\Query\AST\Functions; | ||
|
||
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\ToJson; | ||
use MartinGeorgiev\Tests\Doctrine\Fixtures\Entity\ContainsText; | ||
|
||
class ToJsonTest extends TestCase | ||
{ | ||
protected function getStringFunctions(): array | ||
{ | ||
return [ | ||
'TO_JSON' => ToJson::class, | ||
]; | ||
} | ||
|
||
protected function getExpectedSqlStatements(): array | ||
{ | ||
return [ | ||
'SELECT to_json(c0_.text) AS sclr_0 FROM ContainsText c0_', | ||
'SELECT to_json(UPPER(c0_.text)) AS sclr_0 FROM ContainsText c0_', | ||
'SELECT to_json(1 + 1) AS sclr_0 FROM ContainsText c0_', | ||
'SELECT to_json(1) AS sclr_0 FROM ContainsText c0_', | ||
'SELECT to_json(LENGTH(c0_.text)) AS sclr_0 FROM ContainsText c0_', | ||
]; | ||
} | ||
|
||
protected function getDqlStatements(): array | ||
{ | ||
return [ | ||
\sprintf('SELECT TO_JSON(e.text) FROM %s e', ContainsText::class), | ||
\sprintf('SELECT TO_JSON(UPPER(e.text)) FROM %s e', ContainsText::class), | ||
\sprintf('SELECT TO_JSON(1+1) FROM %s e', ContainsText::class), | ||
\sprintf('SELECT TO_JSON(true) FROM %s e', ContainsText::class), | ||
\sprintf('SELECT TO_JSON(LENGTH(e.text)) FROM %s e', ContainsText::class), | ||
]; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToJsonbTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MartinGeorgiev\Tests\Doctrine\ORM\Query\AST\Functions; | ||
|
||
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\ToJsonb; | ||
use MartinGeorgiev\Tests\Doctrine\Fixtures\Entity\ContainsText; | ||
|
||
class ToJsonbTest extends TestCase | ||
{ | ||
protected function getStringFunctions(): array | ||
{ | ||
return [ | ||
'TO_JSONB' => ToJsonb::class, | ||
]; | ||
} | ||
|
||
protected function getExpectedSqlStatements(): array | ||
{ | ||
return [ | ||
'SELECT to_jsonb(c0_.text) AS sclr_0 FROM ContainsText c0_', | ||
'SELECT to_jsonb(UPPER(c0_.text)) AS sclr_0 FROM ContainsText c0_', | ||
'SELECT to_jsonb(1 + 1) AS sclr_0 FROM ContainsText c0_', | ||
'SELECT to_jsonb(1) AS sclr_0 FROM ContainsText c0_', | ||
'SELECT to_jsonb(LENGTH(c0_.text)) AS sclr_0 FROM ContainsText c0_', | ||
]; | ||
} | ||
|
||
protected function getDqlStatements(): array | ||
{ | ||
return [ | ||
\sprintf('SELECT TO_JSONB(e.text) FROM %s e', ContainsText::class), | ||
\sprintf('SELECT TO_JSONB(UPPER(e.text)) FROM %s e', ContainsText::class), | ||
\sprintf('SELECT TO_JSONB(1+1) FROM %s e', ContainsText::class), | ||
\sprintf('SELECT TO_JSONB(true) FROM %s e', ContainsText::class), | ||
\sprintf('SELECT TO_JSONB(LENGTH(e.text)) FROM %s e', ContainsText::class), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters