Repository navigation
Preserve array element converters with explicit column types - #4007
Merged
Merged
Conversation
Retain element conversion metadata when resolving explicitly typed arrays while preserving column-type precedence. Cover custom enum conversion and explicit integer/bigint element mappings. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c376b6c6-fe3d-412c-819e-f125721cdbaa
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Automatically inferred enum conversions change text-array representations and break compatibility with existing enum-name data.
1 open issue
What changed in this PR
Preserves array element converters when explicit PostgreSQL column types are configured, addressing #3636.
Changes:
- Reuses or recomposes element mappings while honoring explicit store types.
- Adds functional coverage for converted enum arrays.
- Adds unit coverage for integer and bigint array mappings.
| File | Description |
|---|---|
| test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingSourceTest.cs | Tests explicit array types with and without converters. |
| test/EFCore.PG.FunctionalTests/ValueConvertersEndToEndNpgsqlTest.cs | Tests stored strings, round-tripping, and Contains queries. |
| src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs | Preserves element converters during array mapping resolution. |
Review effort: Balanced
| relationalElementMapping = elementType is null | ||
| ? FindMapping(elementStoreType) | ||
| : FindMapping(elementType, elementStoreType)); | ||
| : FindMapping(elementMapping?.Converter?.ProviderClrType ?? elementType, elementStoreType); |
This was referenced Oct 18, 2026
roji
added a commit
that referenced
this pull request
Oct 18, 2026
…4011) * [10.0] Preserve array element converters with explicit column types Backport #4007 to hotfix/10.0.4. Retain element conversion metadata when resolving explicitly typed arrays while preserving column-type precedence. (cherry picked from commit 9357929) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3c63e161-0531-4e0b-9756-a1eb6f999014 * Preserve explicit array element JSON mappings Compose converters over the JSON reader/writer selected for the explicit element store type instead of restoring the inferred writer. This prevents timestamp arrays from reverting to timestamptz JSON serialization and breaking the JSON query/update fixtures. Cover timestamp array JSON serialization with and without an element converter. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3c63e161-0531-4e0b-9756-a1eb6f999014 --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3c63e161-0531-4e0b-9756-a1eb6f999014
roji
added a commit
that referenced
this pull request
Oct 18, 2026
…4014) * [9.0] Preserve array element converters with explicit column types Backport of #4007. Preserve explicit array column-type precedence and adapt the Contains SQL assertion to the 9.0 containment translation. Fixes #3636 (cherry picked from commit 9357929) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: bda9aa2e-f002-4257-9792-18a68ee0b9f2 * Preserve explicit array element JSON mappings Port the correction from the 10.0 backport: compose converters over the JSON reader/writer selected for the explicit element store type instead of restoring the inferred writer. Cover timestamp array JSON serialization with and without an element converter. (cherry picked from commit 842f9cd) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: bda9aa2e-f002-4257-9792-18a68ee0b9f2 --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: bda9aa2e-f002-4257-9792-18a68ee0b9f2
roji
added a commit
that referenced
this pull request
Oct 18, 2026
…4013) * [8.0] Preserve array element converters with explicit column types Backport #4007 to hotfix/8.0.12. Preserve configured array element converters and explicit array store-type precedence. Adapt the regression SQL assertion to the 8.0 Contains translation. (cherry picked from commit 9357929) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 79697333-2969-4518-b96e-46fe5fcb07c3 * Preserve explicit array element JSON mappings Compose converters over the JSON reader/writer selected for the explicit element store type instead of restoring the inferred writer. Cover timestamp array JSON serialization with and without an element converter. (cherry picked from commit 842f9cd) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 79697333-2969-4518-b96e-46fe5fcb07c3 --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 79697333-2969-4518-b96e-46fe5fcb07c3
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Explicit array column types such as
text[]currently discard custom element converters, causing stored values and queries to use enum names instead of the configured strings.Pass the resolved element mapping into array mapping resolution. When its store type differs from the explicit column type, resolve the requested type using the converter's provider CLR type and compose the original converter onto it, retaining comparers and JSON metadata. Explicit column-type precedence is preserved, including
int[]mapped tobigint[]; convention-selected converters are retained as well.Regression coverage in
ValueConvertersEndToEndNpgsqlTestchecks inferred types,text[], andvarchar(16)[]for stored strings, round-tripping, andContainsSQL. Unit coverage checks explicit integer/bigint array mappings with and without custom converters.Fixes #3636