Skip to content

Commit eb41605

Browse files
committed
bug: postgresql - clients types converting
- removed monolithic ArrayConverter in favor of type-specific converters - added BoolArrayConverter for PostgreSQL BOOL[] type - added IntArrayConverter for PostgreSQL INT2[], INT4[], INT8[] types - added FloatArrayConverter for PostgreSQL FLOAT4[], FLOAT8[] types - added TextArrayConverter for PostgreSQL TEXT[], VARCHAR[] types - added UuidArrayConverter for PostgreSQL UUID[] type - added JsonArrayConverter for PostgreSQL JSON[], JSONB[] types - changed array converters to throw ValueConversionException for invalid element types instead of silently converting - added unit tests for each new array converter - removed old ArrayConverterTest.php (unit and integration) - changed ValueConverters.php to register 6 type-specific array converters - added "Array Types" section to documentation/components/libs/postgresql.md - changed documentation/components/libs/postgresql/client-types.md to document array converter validation behavior - fixed syntax highlighing on website - removed symfony/polyfill-83 dependency
1 parent 206e425 commit eb41605

File tree

90 files changed

+2412
-1454
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+2412
-1454
lines changed

composer.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"ext-dom": "*",
1616
"ext-hash": "*",
1717
"ext-json": "*",
18-
"ext-mbstring": "*",
1918
"ext-xml": "*",
2019
"ext-xmlreader": "*",
2120
"ext-xmlwriter": "*",
@@ -42,7 +41,6 @@
4241
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0",
4342
"symfony/console": "^6.4 || ^7.3 || ^8.0",
4443
"symfony/http-foundation": "^6.4 || ^7.3 || ^8.0",
45-
"symfony/polyfill-php83": "^1.33",
4644
"symfony/string": "^6.4 || ^7.3 || ^8.0",
4745
"symfony/uid": "^6.4 || ^7.3 || ^8.0",
4846
"webmozart/glob": "^3.0 || ^4.0"

composer.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

documentation/components/libs/postgresql.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,32 @@ $result = $client->transaction(function ($client) {
306306
$client->close();
307307
```
308308

309+
### Array Types
310+
311+
PostgreSQL arrays are supported through type-specific converters. Use `typed()` with the appropriate array type:
312+
313+
```php
314+
<?php
315+
316+
use function Flow\PostgreSql\DSL\{pgsql_client, pgsql_connection, typed, pgsql_type_int4_array, pgsql_type_text_array};
317+
318+
$client = pgsql_client(pgsql_connection('host=localhost dbname=mydb'));
319+
320+
// Integer array
321+
$client->execute(
322+
'INSERT INTO scores (values) VALUES ($1)',
323+
[typed([100, 200, 300], pgsql_type_int4_array())]
324+
);
325+
326+
// Text array
327+
$client->execute(
328+
'INSERT INTO tags (names) VALUES ($1)',
329+
[typed(['php', 'postgresql'], pgsql_type_text_array())]
330+
);
331+
```
332+
333+
See [Type System](/documentation/components/libs/postgresql/client-types.md) for all supported array types.
334+
309335
### Detailed Documentation
310336

311337
- [Connection](/documentation/components/libs/postgresql/client-connection.md) - Connection parameters, DSN parsing,

documentation/components/libs/postgresql/client-fetching.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ $name = $client->fetchScalarString('SELECT name FROM users WHERE id = $1', [1]);
131131
// $name is guaranteed to be string
132132
```
133133

134-
These methods throw `InvalidTypeException` if the value cannot be converted to the expected type.
134+
These methods throw `QueryException` if the value cannot be converted to the expected type.
135135

136136
## execute() - Data Modification
137137

documentation/components/libs/postgresql/client-types.md

Lines changed: 222 additions & 113 deletions
Large diffs are not rendered by default.

src/core/etl/composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"require": {
1212
"php": "~8.3.0 || ~8.4.0 || ~8.5.0",
1313
"ext-json": "*",
14-
"ext-mbstring": "*",
1514
"psr/clock": "^1.0",
1615
"brick/math": "^0.11 || ^0.12 || ^0.13 || ^0.14",
1716
"flow-php/types": "self.version",

src/lib/postgresql/composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
],
1313
"require": {
1414
"php": "~8.3.0 || ~8.4.0 || ~8.5.0",
15-
"flow-php/types": "self.version",
1615
"google/protobuf": "^4.0"
1716
},
1817
"require-dev": {

src/lib/postgresql/src/Flow/PostgreSql/AST/Nodes/Table.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ public function alias() : ?string
2121
return null;
2222
}
2323

24-
$aliasname = $alias->getAliasname();
25-
26-
return $aliasname !== '' ? $aliasname : null;
24+
return $alias->getAliasname() ?: null;
2725
}
2826

2927
public function name() : string
@@ -38,8 +36,6 @@ public function raw() : RangeVar
3836

3937
public function schema() : ?string
4038
{
41-
$schemaname = $this->rangeVar->getSchemaname();
42-
43-
return $schemaname !== '' ? $schemaname : null;
39+
return $this->rangeVar->getSchemaname() ?: null;
4440
}
4541
}

src/lib/postgresql/src/Flow/PostgreSql/AST/Transformers/KeysetPaginationModifier.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,6 @@ private function createIntegerNode(int $value) : Node
210210

211211
private function hasOrderBy(SelectStmt $stmt) : bool
212212
{
213-
$sortClause = $stmt->getSortClause();
214-
215-
return $sortClause !== null && \count($sortClause) > 0;
213+
return \count($stmt->getSortClause() ?? []) > 0;
216214
}
217215
}

src/lib/postgresql/src/Flow/PostgreSql/AST/Transformers/PaginationModifier.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ private function createIntegerNode(int $value) : Node
9393

9494
private function hasOrderBy(SelectStmt $stmt) : bool
9595
{
96-
$sortClause = $stmt->getSortClause();
97-
98-
return $sortClause !== null && \count($sortClause) > 0;
96+
return \count($stmt->getSortClause() ?? []) > 0;
9997
}
10098

10199
private function isSetOperation(SelectStmt $stmt) : bool

0 commit comments

Comments
 (0)