Skip to content

Conversation

@martin-georgiev
Copy link
Owner

@martin-georgiev martin-georgiev commented Nov 25, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Fixed preservation of trailing zeros in decimal-looking strings stored in text arrays.
    • Improved handling of string types in PostgreSQL array transformations to prevent unwanted type coercion.
  • New Features

    • Added support for optional string-type preservation when converting PostgreSQL arrays to PHP arrays.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 25, 2025

Walkthrough

The changes add a preserveStringTypes parameter to PostgresArrayToPHPArrayTransformer to preserve unquoted Postgres array values as strings rather than inferring numeric or boolean types. TextArray is updated to delegate transformation to this utility with the flag enabled, replacing manual post-processing. New test cases validate type preservation across multiple scenarios.

Changes

Cohort / File(s) Summary
Core transformer enhancement
src/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformer.php
Adds boolean preserveStringTypes parameter (default false) to transformPostgresArrayToPHPArray(). When enabled, bypasses JSON decoding and uses manual parsing that preserves unquoted values as strings. Parameter propagates through parsePostgresArrayManually() and processPostgresValue().
Type implementation refactor
src/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.php
Replaces in-file post-processing of Postgres array values with direct call to PostgresArrayToPHPArrayTransformer::transformPostgresArrayToPHPArray() using preserveStringTypes: true, removing manual type coercion logic.
Transformer unit tests
tests/Unit/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformerTest.php
Adds new test method can_preserve_string_types_when_requested() with data provider providePreserveStringTypesTestCases() covering trailing zeros, scientific notation, quoted values, boolean-like strings, and null preservation.
TextArray unit tests
tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTest.php
Adds new test method can_preserve_trailing_zeros_in_strings_that_look_like_decimals() validating preservation of decimal strings with trailing zeros as distinct string values.
Integration tests
tests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTypeTest.php, tests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTypeTest.php
TextArrayTypeTest adds data provider provideGithubIssue482TestCases() for decimal string scenarios. JsonbArrayTypeTest adds provideTypeInferenceTestCases() data provider for JSON type inference validation.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • PostgresArrayToPHPArrayTransformer.php: Requires careful review of the new preserveStringTypes branching logic, parameter propagation through multiple methods, and the difference between JSON decoding and manual parsing paths
  • Type inference logic in processPostgresValue(): Verify that quoted string unwrapping and raw value return conditions are mutually exclusive and correct
  • Test data providers: Validate that test cases in providePreserveStringTypesTestCases() cover edge cases (empty strings, null preservation, scientific notation as strings)

Possibly related PRs

Poem

🐰 A rabbit hops through postgres arrays,
Preserving strings in so many ways!
With preserveStringTypes flags bright,
Trailing zeros stay in sight—
Types kept true, no type coercion blight! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: preserving strings in TEXTARRAY values during PHP transformation, even when they appear numerical, addressing issue #482.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch issue482

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.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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 thoroughly

The 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 expectedPhpValue is an array<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

📥 Commits

Reviewing files that changed from the base of the PR and between b5aef7d and fadde7b.

📒 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.php
  • tests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTypeTest.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.php
  • src/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformer.php
  • tests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTypeTest.php
  • tests/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.php
  • tests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTypeTest.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.php
  • src/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformer.php
  • tests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTypeTest.php
  • tests/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.php
  • tests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTypeTest.php
  • tests/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.php
  • tests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTypeTest.php
  • tests/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.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.php
  • src/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.php
  • tests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTypeTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTypeTest.php
  • tests/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.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.php
  • src/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformer.php
  • tests/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.php
  • tests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTypeTest.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.php
  • src/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformer.php
  • tests/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.php
  • tests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/TextArrayTypeTest.php
  • tests/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.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.php
  • tests/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.php
  • src/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.php
  • src/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformer.php
  • tests/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 preserveStringTypes parameter to ensure all text array values remain strings, aligning with PostgreSQL text[] 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 JsonbArray maintains JSON-native types (integers, floats, booleans, null) through the transformation cycle. This is the expected behavior for JSONB arrays, contrasting with TextArray which preserves everything as strings.

Note: The float values like 502.00 will be stored as 502.0 in 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 assertSame for 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 provideGithubIssue424TestCases and 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 preserveStringTypes with a default of false maintains backward compatibility for existing callers like JsonbArray while allowing TextArray to opt into string preservation.


80-91: Correct branching for string preservation mode.

When preserveStringTypes is 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 preserveStringTypes is 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 to null, true, or 42.0.

tests/Unit/MartinGeorgiev/Utils/PostgresArrayToPHPArrayTransformerTest.php (1)

266-278: New preserveStringTypes test is correct and well-targeted

The test method correctly exercises the preserveStringTypes: true path, verifies exact value equality with assertSame, and adds a robust per-element assertIsString check so the “all strings” guarantee is explicit. This aligns nicely with the TextArray “strings-only” design.

@coveralls
Copy link

Coverage Status

coverage: 95.687%. first build
when pulling fadde7b on issue482
into b5aef7d on main.

@martin-georgiev martin-georgiev merged commit 77eed3e into main Nov 25, 2025
90 of 92 checks passed
@martin-georgiev martin-georgiev deleted the issue482 branch November 25, 2025 23:52
@github-actions github-actions bot mentioned this pull request Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants