镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Throw for out-of-range SQL Server TimeSpan literals - #39364

Merged
AndriySvyryd merged 1 commit into
dotnet:mainfrom
Saad-elnagar:fix/sqlserver-timespan-literal-range
Oct 22, 2026
Merged

AndriySvyryd merged 1 commit into
dotnet:mainfrom
Saad-elnagar:fix/sqlserver-timespan-literal-range

Conversation

@Saad-elnagar

Copy link
Copy Markdown
Contributor

Fixes #39222

Summary

  • Throw an exception for TimeSpan literals outside SQL Server's supported time range.
  • Add a resource-based error message.
  • Add regression tests for invalid values and valid boundary values.

Tests

  • SQL Server type mapping tests: 92 passed.
  • Full SQL Server test suite: 1431 passed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved review issues were identified, and the supplied assessments unanimously support approval.

No open issues 🎉

1 file not reviewed
  • src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs: Generated file
What changed in this PR

This pull request validates SQL Server TimeSpan literals against the supported time range, preventing invalid values from being generated as SQL.

Changes:

  • Rejects negative and 24-hour-or-longer TimeSpan literals.
  • Adds a localized resource-based overflow message.
  • Adds regression coverage for invalid values, boundary values, and query translation.
File Description
test/​EFCore.SqlServer.Tests/​Storage/​SqlServerTypeMappingTest.cs Covers invalid literals, valid boundaries, and query translation behavior.
src/​EFCore.SqlServer/​Storage/​Internal/​SqlServerTimeSpanTypeMapping.cs Validates TimeSpan values before generating SQL literals.
src/​EFCore.SqlServer/​Properties/​SqlServerStrings.resx Defines the localized out-of-range literal error message.
src/​EFCore.SqlServer/​Properties/​SqlServerStrings.Designer.cs Exposes the generated resource accessor.

Review effort: Lite

@AndriySvyryd AndriySvyryd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid translation for constant negative TimeSpan for SQL Server

3 participants