Skip to content

Wrap TimeOnly subtraction across midnight - #4175

Open
gabisonia wants to merge 1 commit into
npgsql:mainfrom
gabisonia:fix/4148-timeonly-subtraction
Open

gabisonia wants to merge 1 commit into
npgsql:mainfrom
gabisonia:fix/4148-timeonly-subtraction

Conversation

@gabisonia

Copy link
Copy Markdown

Subtracting two TimeOnly values across midnight produces a different result in PostgreSQL and .NET. For example, 00:30 − 23:00 previously returned −22:30 in a LINQ query. It now returns 01:30, matching .NET.

Translate the TimeOnly subtraction operator by casting the signed interval through PostgreSQL time to wrap at midnight, then back to interval for the TimeSpan result. The regression tests cover nullable columns, a parameterized scalar query, equal times, and microsecond precision.

All 427 Release temporal and NodaTime tests passed. An independent check on PostgreSQL 17.6 matched .NET projections, filters, and subsequent arithmetic for 525 stored time pairs.

Fixes #4148.

This branch has not been deployed

No deployments
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.

TimeOnly - TimeOnly returns a negative interval instead of wrapping around midnight

1 participant