Skip to content

Conversation

cincuranet
Copy link
Contributor

Fixes #36479.

Description

Fixes type mapping for GETDATE and GETUTCDATE in SqlServer, which is especially important when comparing with non-column (i.e. constant).

Customer impact

Generated query is rejected by SQL Server and throws error.

How found

Customer reported on 9.

Regression

No.

Testing

Tests added.

Risk

Low. This is a specific case for only these two functions.

Copy link
Member

@artl93 artl93 left a comment

Choose a reason for hiding this comment

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

RC2

Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

Shouldn't we do the same for the other functions down below (e.g. DateTimeOffset.UtcNow)?

The fix looks accurate, but I think there's an additional problem here, in that we always translate DateTime.Now to GETDATE() which returns datetime, although we generally map .NET DateTime to the higher-precision datetime2. I opened #36616 to fix (I don't think it's super important).

@cincuranet cincuranet force-pushed the fix-date branch 2 times, most recently from 9000196 to 46e9c0c Compare August 21, 2025 08:35
@roji
Copy link
Member

roji commented Aug 21, 2025

Shouldn't we do the same for the other functions down below (e.g. DateTimeOffset.UtcNow)?

I'm still seeing an explicit return type mapping for DateTimeOffset.Now, for not for the DateTimeOffset.UtcNow right under it.

@cincuranet cincuranet merged commit 09f9f01 into dotnet:release/10.0 Aug 22, 2025
7 checks passed
@cincuranet cincuranet deleted the fix-date branch August 22, 2025 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EFCore generated an incorrect SQL for DATE
3 participants