Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The fix correctly handles positive and negative sub-microsecond values with comprehensive regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes invalid JSON interval strings by truncating TimeSpan values to PostgreSQL’s microsecond precision before formatting.
Changes:
- Truncates sub-microsecond ticks during interval formatting.
- Adds SQL literal and JSON round-trip regression coverage, including negative values.
| File | Description |
|---|---|
src/EFCore.PG/Storage/Internal/Mapping/NpgsqlIntervalTypeMapping.cs |
Normalizes intervals to microsecond precision before formatting. |
test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingTest.cs |
Tests valid serialization and round-tripping across precision boundaries. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This branch has not been deployed
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.
Fixes #3926.
FormatTimeSpanAsIntervaldecided whether to emit a fractional part using tick precision, but formatted it with microsecond precision (FFFFFF). This produced a trailing.for values with only sub-microsecond ticks. The value is now truncated to microseconds before formatting, which matches howFFFFFFalready truncates. Added a JSON round-trip test covering the cases from the issue.