Repository navigation
Fix nullability metadata for PostgreSQL translations - #4134
Merged
Merged
Conversation
Correct nullable range, date-part, LTree and spatial translations. Fix array_remove propagation and give array concatenation PostgreSQL-specific nullability handling. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The SQL translation change leaves an existing test baseline outdated, causing both sync and async variants of GroupBy_complex_key_aggregate_2 to fail their SQL assertions.
1 open issue
What changed in this PR
This PR corrects nullability metadata in PostgreSQL query translations so EF Core preserves required null compensation and returns the expected rows. It addresses #4084 while leaving DateInterval intersection and union semantics to #4083.
Changes:
- Correct nullability for range bounds, date parts, LTree common ancestors, and spatial accessors.
- Model array concatenation as a PostgreSQL-specific operator and correct
array_removenull propagation. - Add regression tests and update affected SQL expectations.
| File | Description |
|---|---|
| test/EFCore.PG.FunctionalTests/Query/Translations/Temporal/DateTimeTranslationsNpgsqlTest.cs | Tests month comparisons on infinite timestamps. |
| test/EFCore.PG.FunctionalTests/Query/Translations/RangeTranslationsTest.cs | Tests empty and unbounded range bounds. |
| test/EFCore.PG.FunctionalTests/Query/Translations/NodaTime/LocalDateTranslationsTest.cs | Tests month comparisons on infinite dates. |
| test/EFCore.PG.FunctionalTests/Query/Translations/NodaTime/DateIntervalTranslationsTest.cs | Tests null bounds on unbounded date ranges. |
| test/EFCore.PG.FunctionalTests/Query/Translations/LTreeTranslationsTest.cs | Tests null common-ancestor results. |
| test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeometryTest.cs | Tests missing ordinates, empty endpoints, and invalid indexes. |
| test/EFCore.PG.FunctionalTests/Query/PrimitiveCollectionsQueryNpgsqlTest.cs | Tests array null semantics and updates date-part SQL. |
| src/EFCore.PG/Query/NpgsqlSqlExpressionFactory.cs | Adds type mapping for array concatenation. |
| src/EFCore.PG/Query/Internal/NpgsqlSqlNullabilityProcessor.cs | Makes concatenation nullable only when both operands are nullable. |
| src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs | Emits ` |
| src/EFCore.PG/Query/Internal/NpgsqlQueryableMethodTranslatingExpressionVisitor.cs | Uses the array operator and corrects array_remove metadata. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlRangeTranslator.cs | Corrects range-bound nullability. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlLTreeTranslator.cs | Corrects common-ancestor nullability. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlDateTimeMemberTranslator.cs | Corrects date-part nullability. |
| src/EFCore.PG/Query/Expressions/PgExpressionType.cs | Defines the array-concatenation operator. |
| src/EFCore.PG/Query/Expressions/Internal/PgBinaryExpression.cs | Adds array-concatenation expression printing. |
| src/EFCore.PG.NTS/Query/ExpressionTranslators/Internal/NpgsqlNetTopologySuiteMethodCallTranslatorPlugin.cs | Corrects indexed spatial-accessor nullability. |
| src/EFCore.PG.NTS/Query/ExpressionTranslators/Internal/NpgsqlNetTopologySuiteMemberTranslatorPlugin.cs | Corrects ordinate and endpoint nullability. |
| src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeMemberTranslatorPlugin.cs | Corrects date-range bound and date-part nullability. |
Review effort: Balanced
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

Incorrect nullability metadata allows EF to remove required null compensation or add incorrect null checks, silently returning the wrong rows for several PostgreSQL translations.
Correct function metadata for range bounds, date parts, LTree common ancestors, and spatial accessors. Make
array_removepropagate nullability only from its array argument. Represent array concatenation as a PostgreSQL-specific binary operator so it is nullable only when both operands are nullable, while preserving the existing||SQL.DateInterval intersection/union result semantics remain separate in #4083.
Fixes #4084