diff --git a/src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToJson.php b/src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToJson.php index f2f00041..981aaa1e 100644 --- a/src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToJson.php +++ b/src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToJson.php @@ -17,6 +17,6 @@ class ToJson extends BaseFunction protected function customiseFunction(): void { $this->setFunctionPrototype('to_json(%s)'); - $this->addNodeMapping('InputParameter'); + $this->addNodeMapping('NewValue'); } } diff --git a/src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToJsonb.php b/src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToJsonb.php index 804a6114..1271cc3d 100644 --- a/src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToJsonb.php +++ b/src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToJsonb.php @@ -17,6 +17,6 @@ class ToJsonb extends BaseFunction protected function customiseFunction(): void { $this->setFunctionPrototype('to_jsonb(%s)'); - $this->addNodeMapping('InputParameter'); + $this->addNodeMapping('NewValue'); } } diff --git a/tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToJsonTest.php b/tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToJsonTest.php new file mode 100644 index 00000000..8e6e60f3 --- /dev/null +++ b/tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToJsonTest.php @@ -0,0 +1,40 @@ + 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), + ]; + } +} diff --git a/tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToJsonbTest.php b/tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToJsonbTest.php new file mode 100644 index 00000000..c223808a --- /dev/null +++ b/tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToJsonbTest.php @@ -0,0 +1,40 @@ + 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), + ]; + } +} diff --git a/tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsqueryTest.php b/tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsqueryTest.php index f8d4b581..546c41e5 100644 --- a/tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsqueryTest.php +++ b/tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsqueryTest.php @@ -20,6 +20,7 @@ protected function getExpectedSqlStatements(): array { return [ 'SELECT to_tsquery(c0_.text) AS sclr_0 FROM ContainsText c0_', + 'SELECT to_tsquery(UPPER(c0_.text)) AS sclr_0 FROM ContainsText c0_', ]; } @@ -27,6 +28,7 @@ protected function getDqlStatements(): array { return [ \sprintf('SELECT TO_TSQUERY(e.text) FROM %s e', ContainsText::class), + \sprintf('SELECT TO_TSQUERY(UPPER(e.text)) FROM %s e', ContainsText::class), ]; } } diff --git a/tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsvectorTest.php b/tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsvectorTest.php index 479f98f0..e265ae32 100644 --- a/tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsvectorTest.php +++ b/tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsvectorTest.php @@ -20,6 +20,7 @@ protected function getExpectedSqlStatements(): array { return [ 'SELECT to_tsvector(c0_.text) AS sclr_0 FROM ContainsText c0_', + 'SELECT to_tsvector(LOWER(c0_.text)) AS sclr_0 FROM ContainsText c0_', ]; } @@ -27,6 +28,7 @@ protected function getDqlStatements(): array { return [ \sprintf('SELECT TO_TSVECTOR(e.text) FROM %s e', ContainsText::class), + \sprintf('SELECT TO_TSVECTOR(LOWER(e.text)) FROM %s e', ContainsText::class), ]; } }