Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Translation of TimeOnly.FromTimeSpan on SQL Server no-op #34114

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@
&& instance is null
&& arguments.Count == 1)
{
return _sqlExpressionFactory.Convert(arguments[0], typeof(TimeOnly));
return arguments[0].Type is typeof(TimeSpan)

Check failure on line 67 in src/EFCore.SqlServer/Query/Internal/Translators/SqlServerTimeOnlyMethodTranslator.cs

View check run for this annotation

Azure Pipelines / efcore-ci (Build Linux)

src/EFCore.SqlServer/Query/Internal/Translators/SqlServerTimeOnlyMethodTranslator.cs#L67

src/EFCore.SqlServer/Query/Internal/Translators/SqlServerTimeOnlyMethodTranslator.cs(67,41): error CS9135: (NETCORE_ENGINEERING_TELEMETRY=Build) A constant value of type 'Type' is expected

Check failure on line 67 in src/EFCore.SqlServer/Query/Internal/Translators/SqlServerTimeOnlyMethodTranslator.cs

View check run for this annotation

Azure Pipelines / efcore-ci (Build macOS)

src/EFCore.SqlServer/Query/Internal/Translators/SqlServerTimeOnlyMethodTranslator.cs#L67

src/EFCore.SqlServer/Query/Internal/Translators/SqlServerTimeOnlyMethodTranslator.cs(67,41): error CS9135: (NETCORE_ENGINEERING_TELEMETRY=Build) A constant value of type 'Type' is expected

Check failure on line 67 in src/EFCore.SqlServer/Query/Internal/Translators/SqlServerTimeOnlyMethodTranslator.cs

View check run for this annotation

Azure Pipelines / efcore-ci

src/EFCore.SqlServer/Query/Internal/Translators/SqlServerTimeOnlyMethodTranslator.cs#L67

src/EFCore.SqlServer/Query/Internal/Translators/SqlServerTimeOnlyMethodTranslator.cs(67,41): error CS9135: (NETCORE_ENGINEERING_TELEMETRY=Build) A constant value of type 'Type' is expected
Copy link
Contributor

Choose a reason for hiding this comment

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

my bad, my suggestion does not even compile 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that

Suggested change
return arguments[0].Type is typeof(TimeSpan)
return arguments[0].Type == typeof(TimeSpan)

might build... I will try it out tomorrow, so don't trust me on this (well, not yet 😇 )

Copy link
Contributor

Choose a reason for hiding this comment

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

It builds & passes the tests 🚀 (at least locally 😅 )

Copy link
Contributor

Choose a reason for hiding this comment

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

but those 3 tests require updates to the baselines in several files:

  • test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs
  • test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs
  • test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs
  • test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs

? arguments[0]
: _sqlExpressionFactory.Convert(arguments[0], typeof(TimeOnly));
}

if (instance is null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9352,7 +9352,7 @@ public override async Task Where_TimeOnly_FromTimeSpan_compared_to_property(bool
"""
SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline]
FROM [Missions] AS [m]
WHERE CAST([m].[Duration] AS time) < [m].[Time]
WHERE [m].[Duration] < [m].[Time]
""");
}

Expand All @@ -9366,7 +9366,7 @@ public override async Task Where_TimeOnly_FromTimeSpan_compared_to_parameter(boo

SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline]
FROM [Missions] AS [m]
WHERE CAST([m].[Duration] AS time) = @__time_0
WHERE [m].[Duration] = @__time_0
""");
}

Expand All @@ -9378,7 +9378,7 @@ public override async Task Order_by_TimeOnly_FromTimeSpan(bool async)
"""
SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline]
FROM [Missions] AS [m]
ORDER BY CAST([m].[Duration] AS time)
ORDER BY [m].[Duration]
""");
}

Expand Down
Loading