-
-
Notifications
You must be signed in to change notification settings - Fork 56
fix(#482): always preserve strings (even if they are obviously numerical) when transforming a TEXTARRAY value into a PHP array
#488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…cal) when transforming a `TEXTARRAY` value into a PHP array
WalkthroughThe changes add a Changes
Sequence Diagram(s)sequenceDiagram
participant TextArray
participant PostgresArrayToPHPArrayTransformer
rect rgb(200, 220, 240)
Note over TextArray,PostgresArrayToPHPArrayTransformer: New approach with preserveStringTypes
TextArray->>PostgresArrayToPHPArrayTransformer: transformPostgresArrayToPHPArray(postgresArray, preserveStringTypes: true)
activate PostgresArrayToPHPArrayTransformer
alt preserveStringTypes is true
PostgresArrayToPHPArrayTransformer->>PostgresArrayToPHPArrayTransformer: parsePostgresArrayManually(preserveStringTypes: true)
activate PostgresArrayToPHPArrayTransformer
loop for each value
PostgresArrayToPHPArrayTransformer->>PostgresArrayToPHPArrayTransformer: processPostgresValue(preserveStringTypes: true)
Note over PostgresArrayToPHPArrayTransformer: Returns raw unquoted values as strings<br/>Unwraps quoted strings only
end
deactivate PostgresArrayToPHPArrayTransformer
end
PostgresArrayToPHPArrayTransformer-->>TextArray: PHP array with string types preserved
deactivate PostgresArrayToPHPArrayTransformer
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tests/Unit/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformerTest.php (1)
280-327: Data provider covers the critical preserveStringTypes scenarios thoroughlyThe cases look comprehensive for the new behavior: they exercise trailing-zero floats, scientific notation, boolean-/null-like tokens, integers, and mixed quoted/unquoted values, all remaining strings as intended for TextArray. This is well aligned with the repository’s expectation that TextArray yields strings only. Based on learnings, this matches the intended semantics.
As a minor polish only, you could narrow the phpdoc to reflect that
expectedPhpValueis anarray<int, string>:- /** - * @return array<string, array{expectedPhpValue: array, postgresValue: string}> - */ + /** + * @return array<string, array{expectedPhpValue: array<int, string>, postgresValue: string}> + */This is optional and just helps static analysis.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
src/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.php(1 hunks)src/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformer.php(4 hunks)tests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTypeTest.php(2 hunks)tests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTypeTest.php(2 hunks)tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTest.php(1 hunks)tests/Unit/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformerTest.php(1 hunks)
🧰 Additional context used
🧠 Learnings (16)
📓 Common learnings
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 443
File: tests/Unit/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformerTest.php:169-172
Timestamp: 2025-09-06T22:15:32.757Z
Learning: In martin-georgiev/postgresql-for-doctrine, TextArray users should expect the database to normalize data to strings only. The design assumes that intended PHP data for TextArray is always strings, not other data types, which is a reasonable tradeoff that aligns with PostgreSQL text[] type semantics.
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 0
File: :0-0
Timestamp: 2025-03-26T02:46:12.804Z
Learning: The PR "preserve the type of floats and integers when transforming back and forth between PostgreSQL and PHP" improves type handling by ensuring that integers remain integers, floats remain floats, numeric strings stay as strings, and booleans are properly converted through the transformation process.
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 421
File: docs/AVAILABLE-TYPES.md:31-33
Timestamp: 2025-08-19T13:07:15.184Z
Learning: In martin-georgiev/postgresql-for-doctrine, the point[] array type should be documented as "point[]" not "_point" in the AVAILABLE-TYPES.md table, to be consistent with all other array types like text[], jsonb[], inet[], etc.
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 340
File: tests/MartinGeorgiev/Doctrine/DBAL/Types/InetArrayTest.php:145-145
Timestamp: 2025-04-11T11:23:44.192Z
Learning: In the PostgreSQL for Doctrine test cases, methods that test database-to-PHP conversions should use `mixed` type for parameter and include non-string test cases in their data providers, following the pattern in classes like InetTest, CidrTest, and MacaddrTest.
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 421
File: docs/AVAILABLE-TYPES.md:31-33
Timestamp: 2025-08-19T13:07:15.184Z
Learning: In martin-georgiev/postgresql-for-doctrine, the AVAILABLE-TYPES.md documentation table's second column shows DBAL type names (what TYPE_NAME constants contain and getName() method returns) not PostgreSQL internal catalogue names. Array types use the format like 'text[]', 'jsonb[]', 'inet[]' - not the underscore-prefixed PostgreSQL internal names like '_text', '_jsonb', '_inet'.
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 421
File: docs/AVAILABLE-TYPES.md:31-33
Timestamp: 2025-08-19T13:07:15.184Z
Learning: In martin-georgiev/postgresql-for-doctrine, the AVAILABLE-TYPES.md documentation table's second column shows DBAL type names (what getName() method returns) not PostgreSQL internal catalogue names. Array types use the format like 'text[]', 'jsonb[]', 'inet[]' - not the underscore-prefixed PostgreSQL internal names like '_text', '_jsonb', '_inet'.
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 421
File: docs/AVAILABLE-TYPES.md:31-33
Timestamp: 2025-08-19T13:07:15.184Z
Learning: In martin-georgiev/postgresql-for-doctrine, the AVAILABLE-TYPES.md documentation table's second column shows DBAL type names (what getName() method returns) not PostgreSQL internal catalogue names. Array types use the format like 'text[]', 'jsonb[]', 'inet[]' - not the underscore-prefixed PostgreSQL internal names like '_text', '_jsonb', '_inet'.
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 0
File: :0-0
Timestamp: 2025-08-24T16:52:32.488Z
Learning: This repository uses BaseType extension pattern for custom Doctrine DBAL types with PostgreSQL platform assertions, comprehensive unit and integration testing with data providers, and dedicated exception classes for type conversion errors.
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 263
File: src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Numrange.php:19-21
Timestamp: 2025-03-11T12:32:10.726Z
Learning: In the postgresql-for-doctrine repository, PostgreSQL range functions have distinct implementations for different data types. The `Numrange` function works with numeric/decimal values and is tested using the `ContainsDecimals` fixture with properties typed as `float`. In contrast, the `Int4range` function works with 32-bit integers and is tested using the `ContainsIntegers` fixture with properties typed as `int`. While the PHP implementations share a similar structure (extending `BaseFunction`), they are semantically different as they handle different PostgreSQL data types.
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 366
File: tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ArrayPositionsTest.php:1-36
Timestamp: 2025-05-03T00:18:09.078Z
Learning: Always check the current official PostgreSQL documentation at https://www.postgresql.org/docs/ to verify function signatures and behaviors before suggesting improvements or additional tests. The `array_positions` function specifically has a fixed signature with exactly two parameters (array and search value), while `array_position` is variadic with 2-3 parameters.
📚 Learning: 2025-09-06T22:15:32.757Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 443
File: tests/Unit/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformerTest.php:169-172
Timestamp: 2025-09-06T22:15:32.757Z
Learning: In martin-georgiev/postgresql-for-doctrine, TextArray users should expect the database to normalize data to strings only. The design assumes that intended PHP data for TextArray is always strings, not other data types, which is a reasonable tradeoff that aligns with PostgreSQL text[] type semantics.
Applied to files:
tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTest.phptests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTypeTest.phpsrc/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.phpsrc/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformer.phptests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTypeTest.phptests/Unit/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformerTest.php
📚 Learning: 2025-04-11T11:23:44.192Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 340
File: tests/MartinGeorgiev/Doctrine/DBAL/Types/InetArrayTest.php:145-145
Timestamp: 2025-04-11T11:23:44.192Z
Learning: In the PostgreSQL for Doctrine test cases, methods that test database-to-PHP conversions should use `mixed` type for parameter and include non-string test cases in their data providers, following the pattern in classes like InetTest, CidrTest, and MacaddrTest.
Applied to files:
tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTest.phptests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTypeTest.phpsrc/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.phpsrc/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformer.phptests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTypeTest.phptests/Unit/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformerTest.php
📚 Learning: 2025-09-01T18:48:28.508Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 434
File: tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PostGIS/ST_CrossesTest.php:12-31
Timestamp: 2025-09-01T18:48:28.508Z
Learning: When analyzing unit test files in this codebase, always verify the actual file structure and existing patterns before suggesting changes. The ContainsGeometries fixture exists at ./fixtures/MartinGeorgiev/Doctrine/Entity/ContainsGeometries.php and the PostGIS unit tests use the namespace Tests\Unit\MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS consistently.
Applied to files:
tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTest.phptests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTypeTest.phptests/Unit/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformerTest.php
📚 Learning: 2025-03-11T12:32:10.726Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 263
File: src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Numrange.php:19-21
Timestamp: 2025-03-11T12:32:10.726Z
Learning: In the postgresql-for-doctrine repository, PostgreSQL range functions have distinct implementations for different data types. The `Numrange` function works with numeric/decimal values and is tested using the `ContainsDecimals` fixture with properties typed as `float`. In contrast, the `Int4range` function works with 32-bit integers and is tested using the `ContainsIntegers` fixture with properties typed as `int`. While the PHP implementations share a similar structure (extending `BaseFunction`), they are semantically different as they handle different PostgreSQL data types.
Applied to files:
tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTest.phptests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTypeTest.phptests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTypeTest.php
📚 Learning: 2025-08-19T13:07:15.184Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 421
File: docs/AVAILABLE-TYPES.md:31-33
Timestamp: 2025-08-19T13:07:15.184Z
Learning: In martin-georgiev/postgresql-for-doctrine, the point[] array type should be documented as "point[]" not "_point" in the AVAILABLE-TYPES.md table, to be consistent with all other array types like text[], jsonb[], inet[], etc.
Applied to files:
tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTest.phpsrc/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.phpsrc/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformer.php
📚 Learning: 2025-08-24T16:52:32.488Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 0
File: :0-0
Timestamp: 2025-08-24T16:52:32.488Z
Learning: This repository uses BaseType extension pattern for custom Doctrine DBAL types with PostgreSQL platform assertions, comprehensive unit and integration testing with data providers, and dedicated exception classes for type conversion errors.
Applied to files:
tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTest.phptests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTypeTest.phptests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTypeTest.phptests/Unit/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformerTest.php
📚 Learning: 2025-03-26T02:46:12.804Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 0
File: :0-0
Timestamp: 2025-03-26T02:46:12.804Z
Learning: The PR "preserve the type of floats and integers when transforming back and forth between PostgreSQL and PHP" improves type handling by ensuring that integers remain integers, floats remain floats, numeric strings stay as strings, and booleans are properly converted through the transformation process.
Applied to files:
tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTest.phpsrc/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.phpsrc/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformer.phptests/Unit/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformerTest.php
📚 Learning: 2025-08-19T13:07:15.184Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 421
File: docs/AVAILABLE-TYPES.md:31-33
Timestamp: 2025-08-19T13:07:15.184Z
Learning: In martin-georgiev/postgresql-for-doctrine, the AVAILABLE-TYPES.md documentation table's second column shows DBAL type names (what TYPE_NAME constants contain and getName() method returns) not PostgreSQL internal catalogue names. Array types use the format like 'text[]', 'jsonb[]', 'inet[]' - not the underscore-prefixed PostgreSQL internal names like '_text', '_jsonb', '_inet'.
Applied to files:
tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTest.phptests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTypeTest.phpsrc/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.phpsrc/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformer.phptests/Unit/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformerTest.php
📚 Learning: 2025-05-27T16:10:35.054Z
Learnt from: karpilin
Repo: martin-georgiev/postgresql-for-doctrine PR: 386
File: tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTimestampTest.php:34-39
Timestamp: 2025-05-27T16:10:35.054Z
Learning: When reviewing PostgreSQL formatting function tests, the error handling behavior should match PostgreSQL's actual implementation rather than assuming consistency across all formatting functions, as different functions may handle invalid inputs differently.
Applied to files:
tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTest.php
📚 Learning: 2025-04-22T00:03:37.733Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 357
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpMatchTest.php:28-62
Timestamp: 2025-04-22T00:03:37.733Z
Learning: This project focuses on providing Doctrine ORM interfaces to PostgreSQL functions. Tests should validate correct DQL-to-SQL translation rather than PostgreSQL functionality itself. Test cases should focus on parameter passing and SQL generation, not on testing specific PostgreSQL regex pattern behaviors.
Applied to files:
tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTest.phptests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTypeTest.phptests/Unit/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformerTest.php
📚 Learning: 2025-04-20T11:24:18.300Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 352
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpInstrTest.php:1-67
Timestamp: 2025-04-20T11:24:18.300Z
Learning: This PostgreSQL-for-Doctrine project is a translation layer only, focusing on correctly converting Doctrine DQL to PostgreSQL SQL syntax. It ensures arguments are passed in the expected format but does not test or handle PostgreSQL's actual function behavior or data handling. Test cases should focus on DQL-to-SQL translation and argument validation, not on PostgreSQL-specific behaviors.
Applied to files:
tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTest.phpsrc/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.phptests/Unit/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformerTest.php
📚 Learning: 2025-08-09T15:31:42.054Z
Learnt from: landure
Repo: martin-georgiev/postgresql-for-doctrine PR: 411
File: src/MartinGeorgiev/Doctrine/DBAL/Types/Exceptions/InvalidLtreeForPHPException.php:11-19
Timestamp: 2025-08-09T15:31:42.054Z
Learning: In the postgresql-for-doctrine library, exception classes for invalid PHP values (Invalid*ForPHPException) follow a consistent pattern using var_export() in their create() method to format error messages. When adding new exception classes, maintain consistency with existing patterns rather than introducing new approaches, even if technically superior alternatives exist.
Applied to files:
tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTest.php
📚 Learning: 2025-08-19T13:07:15.184Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 421
File: docs/AVAILABLE-TYPES.md:31-33
Timestamp: 2025-08-19T13:07:15.184Z
Learning: In martin-georgiev/postgresql-for-doctrine, the AVAILABLE-TYPES.md documentation table's second column shows DBAL type names (what getName() method returns) not PostgreSQL internal catalogue names. Array types use the format like 'text[]', 'jsonb[]', 'inet[]' - not the underscore-prefixed PostgreSQL internal names like '_text', '_jsonb', '_inet'.
Applied to files:
tests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTypeTest.phpsrc/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.phpsrc/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformer.phptests/Unit/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformerTest.php
📚 Learning: 2025-03-25T01:23:29.749Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 304
File: src/MartinGeorgiev/Utils/DataStructure.php:152-168
Timestamp: 2025-03-25T01:23:29.749Z
Learning: In PostgreSQL text arrays, backslashes must be escaped with triple backslashes. A single backslash in PHP like 'path\to\file' becomes "path\\\to\\\file" in PostgreSQL format.
Applied to files:
src/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.php
📚 Learning: 2025-08-24T16:52:32.488Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 0
File: :0-0
Timestamp: 2025-08-24T16:52:32.488Z
Learning: All new features in this repository must include proper test coverage before approval - this ltree implementation demonstrates exemplary test coverage with comprehensive unit tests, integration tests, data providers for edge cases, and validation of all relationships and error conditions.
Applied to files:
tests/Unit/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformerTest.php
🧬 Code graph analysis (5)
tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTest.php (1)
src/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.php (1)
convertToPHPValue(54-61)
src/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.php (3)
src/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformer.php (2)
PostgresArrayToPHPArrayTransformer(16-261)transformPostgresArrayToPHPArray(32-94)src/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArray.php (1)
transformPostgresArrayToPHPArray(35-38)src/MartinGeorgiev/Doctrine/DBAL/Types/BaseArray.php (1)
transformPostgresArrayToPHPArray(127-135)
src/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformer.php (2)
src/MartinGeorgiev/Utils/PostgresJsonToPHPArrayTransformer.php (1)
transformPostgresArrayToPHPArray(21-34)src/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArray.php (1)
transformPostgresArrayToPHPArray(35-38)
tests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTypeTest.php (1)
tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTest.php (3)
DataProvider(36-41)DataProvider(43-48)DataProvider(126-138)
tests/Unit/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformerTest.php (1)
src/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformer.php (2)
PostgresArrayToPHPArrayTransformer(16-261)transformPostgresArrayToPHPArray(32-94)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
- GitHub Check: PostgreSQL 17 + PostGIS 3.6 + PHP 8.5
- GitHub Check: PostgreSQL 17 + PostGIS 3.4 + PHP 8.5
- GitHub Check: PostgreSQL 17 + PostGIS 3.6 + PHP 8.4
- GitHub Check: PostgreSQL 17 + PostGIS 3.5 + PHP 8.5
- GitHub Check: PostgreSQL 16 + PostGIS 3.5 + PHP 8.4
- GitHub Check: PostgreSQL 16 + PostGIS 3.5 + PHP 8.3
- GitHub Check: PostgreSQL 17 + PostGIS 3.6 + PHP 8.2
- GitHub Check: PostgreSQL 18 + PostGIS 3.6 + PHP 8.2
- GitHub Check: PostgreSQL 17 + PostGIS 3.6 + PHP 8.3
- GitHub Check: PostgreSQL 16 + PostGIS 3.4 + PHP 8.3
- GitHub Check: PostgreSQL 16 + PostGIS 3.5 + PHP 8.2
- GitHub Check: PostgreSQL 17 + PostGIS 3.5 + PHP 8.1
- GitHub Check: PostgreSQL 16 + PostGIS 3.4 + PHP 8.1
- GitHub Check: PostgreSQL 17 + PostGIS 3.6 + PHP 8.1
- GitHub Check: PostgreSQL 16 + PostGIS 3.4 + PHP 8.2
- GitHub Check: PostgreSQL 18 + PostGIS 3.6 + PHP 8.1
- GitHub Check: PostgreSQL 17 + PostGIS 3.4 + PHP 8.2
- GitHub Check: PostgreSQL 17 + PostGIS 3.4 + PHP 8.1
- GitHub Check: PostgreSQL 16 + PostGIS 3.5 + PHP 8.1
🔇 Additional comments (8)
src/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.php (1)
63-69: Clean delegation to transformer with string preservation enabled.This correctly leverages the new
preserveStringTypesparameter to ensure all text array values remain strings, aligning with PostgreSQLtext[]semantics. The named parameter improves readability. Based on learnings, TextArray users should expect the database to normalize data to strings only.tests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTypeTest.php (1)
77-117: Well-structured type inference test cases for JsonbArray.These tests correctly validate that
JsonbArraymaintains JSON-native types (integers, floats, booleans, null) through the transformation cycle. This is the expected behavior for JSONB arrays, contrasting withTextArraywhich preserves everything as strings.Note: The float values like
502.00will be stored as502.0in PHP (float type loses trailing zeros), which is correct for JSONB semantics where numeric precision follows JSON rules.tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTest.php (1)
183-196: Targeted test for GitHub issue #482.This test directly verifies the fix for trailing zero preservation in decimal-looking strings. Good use of
assertSamefor strict type comparison and individual type assertions for each element.tests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTypeTest.php (1)
87-107: Comprehensive integration test coverage for issue #482.The new data provider follows the established pattern from
provideGithubIssue424TestCasesand the docblock clearly documents the issue context. These test cases will validate the fix through actual PostgreSQL round-trips.src/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformer.php (3)
32-32: Backward-compatible API extension.Adding
preserveStringTypeswith a default offalsemaintains backward compatibility for existing callers likeJsonbArraywhile allowingTextArrayto opt into string preservation.
80-91: Correct branching for string preservation mode.When
preserveStringTypesis enabled, bypassing JSON decoding is the right approach since JSON parsing would infer numeric types from values like"42.00"and lose trailing zeros. The early return to manual parsing ensures string fidelity.
151-161: String preservation logic handles edge cases correctly.When
preserveStringTypesis true:
- Quoted strings are still properly unquoted/unescaped (line 156-158)
- Unquoted values (including
NULL,true, numeric-looking strings) are returned verbatim as strings (line 160)This ensures text arrays preserve values like
"null","true", and"42.00"as strings rather than converting tonull,true, or42.0.tests/Unit/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformerTest.php (1)
266-278: New preserveStringTypes test is correct and well-targetedThe test method correctly exercises the
preserveStringTypes: truepath, verifies exact value equality withassertSame, and adds a robust per-elementassertIsStringcheck so the “all strings” guarantee is explicit. This aligns nicely with the TextArray “strings-only” design.
Summary by CodeRabbit
Bug Fixes
New Features
✏️ Tip: You can customize this high-level summary in your review settings.