From 417074283b053bc6ff284a6db74e7ab80b50a74b Mon Sep 17 00:00:00 2001 From: danevandy99 Date: Sat, 11 May 2024 17:43:31 -0700 Subject: [PATCH 1/2] Fixes #20604 --- .../SqlServerObjectToStringTranslator.cs | 5 + .../SqliteObjectToStringTranslator.cs | 2 +- .../Query/GearsOfWarQueryInMemoryTest.cs | 16 +++ .../Query/GearsOfWarQueryFixtureBase.cs | 7 +- .../Query/GearsOfWarQueryTestBase.cs | 41 ++++-- .../GearsOfWarModel/GearsOfWarData.cs | 9 +- .../TestModels/GearsOfWarModel/Mission.cs | 1 + .../GearsOfWarModel/MissionDifficulty.cs | 13 ++ .../Query/GearsOfWarQuerySqlServerTest.cs | 126 +++++++++++------- .../Query/TPCGearsOfWarQuerySqlServerTest.cs | 110 +++++++++------ .../Query/TPTGearsOfWarQuerySqlServerTest.cs | 106 ++++++++++----- .../TemporalGearsOfWarQuerySqlServerTest.cs | 122 +++++++++++------ .../Query/GearsOfWarQuerySqliteTest.cs | 80 +++++++---- 13 files changed, 436 insertions(+), 202 deletions(-) create mode 100644 test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/MissionDifficulty.cs diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs index 10d9b5da5bd..76ba1235fc5 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs @@ -101,6 +101,11 @@ public SqlServerObjectToStringTranslator(ISqlExpressionFactory sqlExpressionFact _sqlExpressionFactory.Constant(true.ToString())); } + if (instance.Type.IsEnum) + { + return _sqlExpressionFactory.Convert(instance, typeof(string)); + } + return TypeMapping.TryGetValue(instance.Type, out var storeType) ? _sqlExpressionFactory.Function( "CONVERT", diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteObjectToStringTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteObjectToStringTranslator.cs index 2cd849f420d..a1011a64a54 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteObjectToStringTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteObjectToStringTranslator.cs @@ -98,7 +98,7 @@ public SqliteObjectToStringTranslator(ISqlExpressionFactory sqlExpressionFactory _sqlExpressionFactory.Constant(true.ToString())); } - return TypeMapping.Contains(instance.Type) + return TypeMapping.Contains(instance.Type)|| instance.Type.IsEnum ? _sqlExpressionFactory.Convert(instance, typeof(string)) : null; } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/GearsOfWarQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/GearsOfWarQueryInMemoryTest.cs index 0d1de5d6be7..7acd362e4e9 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/GearsOfWarQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/GearsOfWarQueryInMemoryTest.cs @@ -139,4 +139,20 @@ public override Task Where_compare_anonymous_types(bool async) public override Task Subquery_inside_Take_argument(bool async) => Task.CompletedTask; + + public override Task ToString_nullable_enum_property_projection(bool async) + => AssertQuery( + async, + ss => ss.Set().Select(w => w.AmmunitionType.ToString()), + ss => ss.Set().Select(w => w.AmmunitionType != null ? w.AmmunitionType.ToString() : null)); + + public override Task ToString_nullable_enum_contains(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(w => w.AmmunitionType.ToString().Contains("Cart")).Select(g => g.Name)); + + public override Task ToString_enum_property_projection(bool async) + => AssertQuery( + async, + ss => ss.Set().Select(g => g.Rank.ToString())); } diff --git a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs index 8f7e92bb6b9..99254d2ccef 100644 --- a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs @@ -337,7 +337,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.HasOne(w => w.Owner).WithMany(g => g.Weapons).HasForeignKey(w => w.OwnerFullName).HasPrincipalKey(g => g.FullName); }); - modelBuilder.Entity().Property(m => m.Id).ValueGeneratedNever(); + modelBuilder.Entity( + b => + { + b.Property(m => m.Id).ValueGeneratedNever(); + b.Property(m => m.Difficulty).HasConversion(); + }); modelBuilder.Entity( b => diff --git a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs index 2a274599198..8332182f62e 100644 --- a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs @@ -89,6 +89,37 @@ public virtual Task ToString_boolean_property_nullable(bool async) async, ss => ss.Set().Select(lh => lh.Eradicated.ToString())); + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task ToString_enum_property_projection(bool async) + => AssertQuery( + async, + ss => ss.Set().Select(g => g.Rank.ToString()), + ss => ss.Set().Select(g => ((int)g.Rank).ToString())); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task ToString_nullable_enum_property_projection(bool async) + => AssertQuery( + async, + ss => ss.Set().Select(w => w.AmmunitionType.ToString()), + ss => ss.Set().Select(w => w.AmmunitionType != null ? ((int)w.AmmunitionType).ToString() : null)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task ToString_enum_contains(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(g => g.Difficulty.ToString().Contains("Med")).Select(g => g.CodeName)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task ToString_nullable_enum_contains(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(w => w.AmmunitionType.ToString().Contains("1")).Select(g => g.Name), + ss => ss.Set().Where(w => w.AmmunitionType != null && ((int?)w.AmmunitionType).ToString().Contains("1")).Select(g => g.Name)); + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Include_multiple_one_to_one_and_one_to_many_self_reference(bool async) @@ -3118,16 +3149,6 @@ public virtual Task Projecting_nullable_bool_in_conditional_works(bool async) new { Prop = cg.Gear != null ? cg.Gear.HasSoulPatch : false }), e => e.Prop); - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Enum_ToString_is_client_eval(bool async) - => AssertQuery( - async, - ss => - ss.Set().OrderBy(g => g.SquadId) - .ThenBy(g => g.Nickname) - .Select(g => g.Rank.ToString())); - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Correlated_collections_naked_navigation_with_ToList(bool async) diff --git a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs index 9bc92293bcf..b80c9789e05 100644 --- a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs +++ b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs @@ -133,7 +133,8 @@ public static IReadOnlyList CreateMissions() Timeline = new DateTimeOffset(599898024001234567, new TimeSpan(1, 30, 0)), Duration = new TimeSpan(1, 2, 3), Date = new DateOnly(2020, 1, 1), - Time = new TimeOnly(15, 30, 10) + Time = new TimeOnly(15, 30, 10), + Difficulty = MissionDifficulty.Low }, new() { @@ -143,7 +144,8 @@ public static IReadOnlyList CreateMissions() Timeline = new DateTimeOffset(2, 3, 1, 8, 0, 0, new TimeSpan(-5, 0, 0)), Duration = new TimeSpan(0, 1, 2, 3, 456), Date = new DateOnly(1990, 11, 10), - Time = new TimeOnly(10, 15, 50, 500) + Time = new TimeOnly(10, 15, 50, 500), + Difficulty = MissionDifficulty.Medium }, new() { @@ -153,7 +155,8 @@ public static IReadOnlyList CreateMissions() Timeline = new DateTimeOffset(10, 5, 3, 12, 0, 0, new TimeSpan()), Duration = new TimeSpan(0, 1, 0, 15, 456), Date = new DateOnly(1, 1, 1), - Time = new TimeOnly(0, 0, 0) + Time = new TimeOnly(0, 0, 0), + Difficulty = MissionDifficulty.Unknown } }; diff --git a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Mission.cs b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Mission.cs index e95dce09e07..9771ca758ba 100644 --- a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Mission.cs +++ b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Mission.cs @@ -13,6 +13,7 @@ public class Mission public TimeSpan Duration { get; set; } public DateOnly Date { get; set; } public TimeOnly Time { get; set; } + public MissionDifficulty Difficulty { get; set; } public virtual ICollection ParticipatingSquads { get; set; } } diff --git a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/MissionDifficulty.cs b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/MissionDifficulty.cs new file mode 100644 index 00000000000..e01ccc39e24 --- /dev/null +++ b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/MissionDifficulty.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel; + +public enum MissionDifficulty +{ + Unknown = 0, + Low = 1, + Medium = 2, + High = 3, + Extreme = 4 +} diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs index 306f963eec0..ecfc56b2bd0 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs @@ -2707,7 +2707,7 @@ public override async Task Where_datetimeoffset_now(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 [m].[Timeline] <> SYSDATETIMEOFFSET() """); @@ -2719,7 +2719,7 @@ public override async Task Where_datetimeoffset_utcnow(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 [m].[Timeline] <> CAST(SYSUTCDATETIME() AS datetimeoffset) """); @@ -2733,7 +2733,7 @@ public override async Task Where_datetimeoffset_date_component(bool async) """ @__Date_0='0001-01-01T00:00:00.0000000' -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 CONVERT(date, [m].[Timeline]) > @__Date_0 """); @@ -2745,7 +2745,7 @@ public override async Task Where_datetimeoffset_year_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEPART(year, [m].[Timeline]) = 2 """); @@ -2757,7 +2757,7 @@ public override async Task Where_datetimeoffset_month_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEPART(month, [m].[Timeline]) = 1 """); @@ -2769,7 +2769,7 @@ public override async Task Where_datetimeoffset_dayofyear_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEPART(dayofyear, [m].[Timeline]) = 2 """); @@ -2781,7 +2781,7 @@ public override async Task Where_datetimeoffset_day_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEPART(day, [m].[Timeline]) = 2 """); @@ -2793,7 +2793,7 @@ public override async Task Where_datetimeoffset_hour_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEPART(hour, [m].[Timeline]) = 10 """); @@ -2805,7 +2805,7 @@ public override async Task Where_datetimeoffset_minute_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEPART(minute, [m].[Timeline]) = 0 """); @@ -2817,7 +2817,7 @@ public override async Task Where_datetimeoffset_second_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEPART(second, [m].[Timeline]) = 0 """); @@ -2829,7 +2829,7 @@ public override async Task Where_datetimeoffset_millisecond_component(bool async AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEPART(millisecond, [m].[Timeline]) = 0 """); @@ -2930,7 +2930,7 @@ public virtual async Task Where_AtTimeZone_datetime_constant(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 [m].[Timeline] = CAST('0010-05-03T12:00:00.0000000' AS datetime2) AT TIME ZONE 'UTC' """); @@ -2958,7 +2958,7 @@ public virtual async Task Where_AtTimeZone_datetime_parameter(bool async) @__dateTime_1='0010-05-03T12:00:00.0000000' @__timeZone_2='UTC' (Size = 8000) (DbType = AnsiString) -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 [m].[Timeline] = @__dateTime_1 AT TIME ZONE @__timeZone_2 """); @@ -3987,18 +3987,6 @@ FROM [Tags] AS [t] """); } - public override async Task Enum_ToString_is_client_eval(bool async) - { - await base.Enum_ToString_is_client_eval(async); - - AssertSql( - """ -SELECT [g].[Rank] -FROM [Gears] AS [g] -ORDER BY [g].[SquadId], [g].[Nickname] -"""); - } - public override async Task ToString_string_property_projection(bool async) { await base.ToString_string_property_projection(async); @@ -4039,6 +4027,52 @@ FROM [Factions] AS [f] """); } + public override async Task ToString_enum_property_projection(bool async) + { + await base.ToString_enum_property_projection(async); + + AssertSql( + """ +SELECT CAST([g].[Rank] AS nvarchar(max)) +FROM [Gears] AS [g] +"""); + } + + public override async Task ToString_nullable_enum_property_projection(bool async) + { + await base.ToString_nullable_enum_property_projection(async); + + AssertSql( + """ +SELECT CAST([w].[AmmunitionType] AS nvarchar(max)) +FROM [Weapons] AS [w] +"""); + } + + public override async Task ToString_enum_contains(bool async) + { + await base.ToString_enum_contains(async); + + AssertSql( + """ +SELECT [m].[CodeName] +FROM [Missions] AS [m] +WHERE CAST([m].[Difficulty] AS nvarchar(max)) LIKE N'%Med%' +"""); + } + + public override async Task ToString_nullable_enum_contains(bool async) + { + await base.ToString_nullable_enum_contains(async); + + AssertSql( + """ +SELECT [w].[Name] +FROM [Weapons] AS [w] +WHERE CAST([w].[AmmunitionType] AS nvarchar(max)) LIKE N'%1%' +"""); + } + public override async Task Correlated_collections_naked_navigation_with_ToList(bool async) { await base.Correlated_collections_naked_navigation_with_ToList(async); @@ -6662,7 +6696,7 @@ public override async Task DateTimeOffset_Contains_Less_than_Greater_than(bool a @__end_1='1902-01-03T10:00:00.1234567+01:30' @__dates_2='["1902-01-02T10:00:00.1234567+01:30"]' (Size = 4000) -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 @__start_0 <= CAST(CONVERT(date, [m].[Timeline]) AS datetimeoffset) AND [m].[Timeline] < @__end_1 AND [m].[Timeline] IN ( SELECT [d].[value] @@ -7722,7 +7756,7 @@ public override async Task DateTimeOffset_Date_returns_datetime(bool async) """ @__dateTimeOffset_Date_0='0002-03-01T00:00:00.0000000' -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 CONVERT(date, [m].[Timeline]) >= @__dateTimeOffset_Date_0 """); @@ -7882,7 +7916,7 @@ public override async Task Where_TimeSpan_Hours(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEPART(hour, [m].[Duration]) = 1 """); @@ -7894,7 +7928,7 @@ public override async Task Where_TimeSpan_Minutes(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEPART(minute, [m].[Duration]) = 2 """); @@ -7906,7 +7940,7 @@ public override async Task Where_TimeSpan_Seconds(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEPART(second, [m].[Duration]) = 3 """); @@ -7918,7 +7952,7 @@ public override async Task Where_TimeSpan_Milliseconds(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEPART(millisecond, [m].[Duration]) = 456 """); @@ -9069,7 +9103,7 @@ public override async Task Where_DateOnly_Year(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEPART(year, [m].[Date]) = 1990 """); @@ -9081,7 +9115,7 @@ public override async Task Where_DateOnly_Month(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEPART(month, [m].[Date]) = 11 """); @@ -9093,7 +9127,7 @@ public override async Task Where_DateOnly_Day(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEPART(day, [m].[Date]) = 10 """); @@ -9105,7 +9139,7 @@ public override async Task Where_DateOnly_DayOfYear(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEPART(dayofyear, [m].[Date]) = 314 """); @@ -9124,7 +9158,7 @@ public override async Task Where_DateOnly_AddYears(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEADD(year, CAST(3 AS int), [m].[Date]) = '1993-11-10' """); @@ -9136,7 +9170,7 @@ public override async Task Where_DateOnly_AddMonths(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEADD(month, CAST(3 AS int), [m].[Date]) = '1991-02-10' """); @@ -9148,7 +9182,7 @@ public override async Task Where_DateOnly_AddDays(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEADD(day, CAST(3 AS int), [m].[Date]) = '1990-11-13' """); @@ -9160,7 +9194,7 @@ public override async Task Where_TimeOnly_Hour(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEPART(hour, [m].[Time]) = 10 """); @@ -9172,7 +9206,7 @@ public override async Task Where_TimeOnly_Minute(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEPART(minute, [m].[Time]) = 15 """); @@ -9184,7 +9218,7 @@ public override async Task Where_TimeOnly_Second(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEPART(second, [m].[Time]) = 50 """); @@ -9196,7 +9230,7 @@ public override async Task Where_TimeOnly_Millisecond(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEPART(millisecond, [m].[Time]) = 500 """); @@ -9208,7 +9242,7 @@ public override async Task Where_TimeOnly_AddHours(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEADD(hour, CAST(3.0E0 AS int), [m].[Time]) = '13:15:50.5' """); @@ -9220,7 +9254,7 @@ public override async Task Where_TimeOnly_AddMinutes(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 DATEADD(minute, CAST(3.0E0 AS int), [m].[Time]) = '10:18:50.5' """); @@ -9239,7 +9273,7 @@ public override async Task Where_TimeOnly_IsBetween(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 CASE WHEN [m].[Time] >= '10:00:00' THEN CAST(1 AS bit) @@ -9530,7 +9564,7 @@ public override async Task Where_equals_method_on_nullable_with_object_overload( AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +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 [m].[Rating] IS NULL """); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs index a63f180c678..58f8bf11b90 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs @@ -3779,7 +3779,7 @@ public override async Task Where_datetimeoffset_now(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE [m].[Timeline] <> SYSDATETIMEOFFSET() """); @@ -3791,7 +3791,7 @@ public override async Task Where_datetimeoffset_utcnow(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE [m].[Timeline] <> CAST(SYSUTCDATETIME() AS datetimeoffset) """); @@ -3805,7 +3805,7 @@ public override async Task Where_datetimeoffset_date_component(bool async) """ @__Date_0='0001-01-01T00:00:00.0000000' -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE CONVERT(date, [m].[Timeline]) > @__Date_0 """); @@ -3817,7 +3817,7 @@ public override async Task Where_datetimeoffset_year_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(year, [m].[Timeline]) = 2 """); @@ -3829,7 +3829,7 @@ public override async Task Where_datetimeoffset_month_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(month, [m].[Timeline]) = 1 """); @@ -3841,7 +3841,7 @@ public override async Task Where_datetimeoffset_dayofyear_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(dayofyear, [m].[Timeline]) = 2 """); @@ -3853,7 +3853,7 @@ public override async Task Where_datetimeoffset_day_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(day, [m].[Timeline]) = 2 """); @@ -3865,7 +3865,7 @@ public override async Task Where_datetimeoffset_hour_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(hour, [m].[Timeline]) = 10 """); @@ -3877,7 +3877,7 @@ public override async Task Where_datetimeoffset_minute_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(minute, [m].[Timeline]) = 0 """); @@ -3889,7 +3889,7 @@ public override async Task Where_datetimeoffset_second_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(second, [m].[Timeline]) = 0 """); @@ -3901,7 +3901,7 @@ public override async Task Where_datetimeoffset_millisecond_component(bool async AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(millisecond, [m].[Timeline]) = 0 """); @@ -5382,21 +5382,55 @@ FROM [Officers] AS [o] """); } - public override async Task Enum_ToString_is_client_eval(bool async) + public override async Task ToString_enum_property_projection(bool async) { - await base.Enum_ToString_is_client_eval(async); + await base.ToString_enum_property_projection(async); AssertSql( """ -SELECT [t].[Rank] +SELECT CAST([t].[Rank] AS nvarchar(max)) FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[Rank] + SELECT [g].[Rank] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[Rank] + SELECT [o].[Rank] FROM [Officers] AS [o] ) AS [t] -ORDER BY [t].[SquadId], [t].[Nickname] +"""); + } + + public override async Task ToString_nullable_enum_property_projection(bool async) + { + await base.ToString_nullable_enum_property_projection(async); + + AssertSql( +""" +SELECT CAST([w].[AmmunitionType] AS nvarchar(max)) +FROM [Weapons] AS [w] +"""); + } + + public override async Task ToString_enum_contains(bool async) + { + await base.ToString_enum_contains(async); + + AssertSql( +""" +SELECT [m].[CodeName] +FROM [Missions] AS [m] +WHERE CAST([m].[Difficulty] AS nvarchar(max)) LIKE N'%Med%' +"""); + } + + public override async Task ToString_nullable_enum_contains(bool async) + { + await base.ToString_nullable_enum_contains(async); + + AssertSql( + """ +SELECT [w].[Name] +FROM [Weapons] AS [w] +WHERE CAST([w].[AmmunitionType] AS nvarchar(max)) LIKE N'%1%' """); } @@ -8956,7 +8990,7 @@ public override async Task DateTimeOffset_Contains_Less_than_Greater_than(bool a @__end_1='1902-01-03T10:00:00.1234567+01:30' @__dates_2='["1902-01-02T10:00:00.1234567+01:30"]' (Size = 4000) -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE @__start_0 <= CAST(CONVERT(date, [m].[Timeline]) AS datetimeoffset) AND [m].[Timeline] < @__end_1 AND [m].[Timeline] IN ( SELECT [d].[value] @@ -10271,7 +10305,7 @@ public override async Task DateTimeOffset_Date_returns_datetime(bool async) """ @__dateTimeOffset_Date_0='0002-03-01T00:00:00.0000000' -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE CONVERT(date, [m].[Timeline]) >= @__dateTimeOffset_Date_0 """); @@ -10461,7 +10495,7 @@ public override async Task Where_TimeSpan_Hours(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(hour, [m].[Duration]) = 1 """); @@ -10473,7 +10507,7 @@ public override async Task Where_TimeSpan_Minutes(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(minute, [m].[Duration]) = 2 """); @@ -10485,7 +10519,7 @@ public override async Task Where_TimeSpan_Seconds(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(second, [m].[Duration]) = 3 """); @@ -10497,7 +10531,7 @@ public override async Task Where_TimeSpan_Milliseconds(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(millisecond, [m].[Duration]) = 456 """); @@ -11662,7 +11696,7 @@ public override async Task Where_DateOnly_Year(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(year, [m].[Date]) = 1990 """); @@ -11674,7 +11708,7 @@ public override async Task Where_DateOnly_Month(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(month, [m].[Date]) = 11 """); @@ -11686,7 +11720,7 @@ public override async Task Where_DateOnly_Day(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(day, [m].[Date]) = 10 """); @@ -11698,7 +11732,7 @@ public override async Task Where_DateOnly_DayOfYear(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(dayofyear, [m].[Date]) = 314 """); @@ -11717,7 +11751,7 @@ public override async Task Where_DateOnly_AddYears(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEADD(year, CAST(3 AS int), [m].[Date]) = '1993-11-10' """); @@ -11729,7 +11763,7 @@ public override async Task Where_DateOnly_AddMonths(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEADD(month, CAST(3 AS int), [m].[Date]) = '1991-02-10' """); @@ -11741,7 +11775,7 @@ public override async Task Where_DateOnly_AddDays(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEADD(day, CAST(3 AS int), [m].[Date]) = '1990-11-13' """); @@ -11753,7 +11787,7 @@ public override async Task Where_TimeOnly_Hour(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(hour, [m].[Time]) = 10 """); @@ -11765,7 +11799,7 @@ public override async Task Where_TimeOnly_Minute(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(minute, [m].[Time]) = 15 """); @@ -11777,7 +11811,7 @@ public override async Task Where_TimeOnly_Second(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(second, [m].[Time]) = 50 """); @@ -11789,7 +11823,7 @@ public override async Task Where_TimeOnly_Millisecond(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(millisecond, [m].[Time]) = 500 """); @@ -11801,7 +11835,7 @@ public override async Task Where_TimeOnly_AddHours(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEADD(hour, CAST(3.0E0 AS int), [m].[Time]) = '13:15:50.5' """); @@ -11813,7 +11847,7 @@ public override async Task Where_TimeOnly_AddMinutes(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEADD(minute, CAST(3.0E0 AS int), [m].[Time]) = '10:18:50.5' """); @@ -11832,7 +11866,7 @@ public override async Task Where_TimeOnly_IsBetween(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE CASE WHEN [m].[Time] >= '10:00:00' THEN CAST(1 AS bit) @@ -12401,7 +12435,7 @@ public override async Task Where_equals_method_on_nullable_with_object_overload( AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE [m].[Rating] IS NULL """); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs index 25ea3820a68..0aa173e9bd6 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs @@ -3234,7 +3234,7 @@ public override async Task Where_datetimeoffset_now(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE [m].[Timeline] <> SYSDATETIMEOFFSET() """); @@ -3246,7 +3246,7 @@ public override async Task Where_datetimeoffset_utcnow(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE [m].[Timeline] <> CAST(SYSUTCDATETIME() AS datetimeoffset) """); @@ -3260,7 +3260,7 @@ public override async Task Where_datetimeoffset_date_component(bool async) """ @__Date_0='0001-01-01T00:00:00.0000000' -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE CONVERT(date, [m].[Timeline]) > @__Date_0 """); @@ -3272,7 +3272,7 @@ public override async Task Where_datetimeoffset_year_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(year, [m].[Timeline]) = 2 """); @@ -3284,7 +3284,7 @@ public override async Task Where_datetimeoffset_month_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(month, [m].[Timeline]) = 1 """); @@ -3296,7 +3296,7 @@ public override async Task Where_datetimeoffset_dayofyear_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(dayofyear, [m].[Timeline]) = 2 """); @@ -3308,7 +3308,7 @@ public override async Task Where_datetimeoffset_day_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(day, [m].[Timeline]) = 2 """); @@ -3320,7 +3320,7 @@ public override async Task Where_datetimeoffset_hour_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(hour, [m].[Timeline]) = 10 """); @@ -3332,7 +3332,7 @@ public override async Task Where_datetimeoffset_minute_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(minute, [m].[Timeline]) = 0 """); @@ -3344,7 +3344,7 @@ public override async Task Where_datetimeoffset_second_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(second, [m].[Timeline]) = 0 """); @@ -3356,7 +3356,7 @@ public override async Task Where_datetimeoffset_millisecond_component(bool async AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(millisecond, [m].[Timeline]) = 0 """); @@ -4717,15 +4717,49 @@ FROM [Gears] AS [g] """); } - public override async Task Enum_ToString_is_client_eval(bool async) + public override async Task ToString_enum_property_projection(bool async) { - await base.Enum_ToString_is_client_eval(async); + await base.ToString_enum_property_projection(async); AssertSql( """ -SELECT [g].[Rank] +SELECT CAST([g].[Rank] AS nvarchar(max)) FROM [Gears] AS [g] -ORDER BY [g].[SquadId], [g].[Nickname] +"""); + } + + public override async Task ToString_nullable_enum_property_projection(bool async) + { + await base.ToString_nullable_enum_property_projection(async); + + AssertSql( +""" +SELECT CAST([w].[AmmunitionType] AS nvarchar(max)) +FROM [Weapons] AS [w] +"""); + } + + public override async Task ToString_enum_contains(bool async) + { + await base.ToString_enum_contains(async); + + AssertSql( + """ +SELECT [m].[CodeName] +FROM [Missions] AS [m] +WHERE CAST([m].[Difficulty] AS nvarchar(max)) LIKE N'%Med%' +"""); + } + + public override async Task ToString_nullable_enum_contains(bool async) + { + await base.ToString_nullable_enum_contains(async); + + AssertSql( + """ +SELECT [w].[Name] +FROM [Weapons] AS [w] +WHERE CAST([w].[AmmunitionType] AS nvarchar(max)) LIKE N'%1%' """); } @@ -7622,7 +7656,7 @@ public override async Task DateTimeOffset_Contains_Less_than_Greater_than(bool a @__end_1='1902-01-03T10:00:00.1234567+01:30' @__dates_2='["1902-01-02T10:00:00.1234567+01:30"]' (Size = 4000) -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE @__start_0 <= CAST(CONVERT(date, [m].[Timeline]) AS datetimeoffset) AND [m].[Timeline] < @__end_1 AND [m].[Timeline] IN ( SELECT [d].[value] @@ -8815,7 +8849,7 @@ public override async Task DateTimeOffset_Date_returns_datetime(bool async) """ @__dateTimeOffset_Date_0='0002-03-01T00:00:00.0000000' -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE CONVERT(date, [m].[Timeline]) >= @__dateTimeOffset_Date_0 """); @@ -8981,7 +9015,7 @@ public override async Task Where_TimeSpan_Hours(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(hour, [m].[Duration]) = 1 """); @@ -8993,7 +9027,7 @@ public override async Task Where_TimeSpan_Minutes(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(minute, [m].[Duration]) = 2 """); @@ -9005,7 +9039,7 @@ public override async Task Where_TimeSpan_Seconds(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(second, [m].[Duration]) = 3 """); @@ -9017,7 +9051,7 @@ public override async Task Where_TimeSpan_Milliseconds(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(millisecond, [m].[Duration]) = 456 """); @@ -9971,7 +10005,7 @@ public override async Task Where_DateOnly_Year(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(year, [m].[Date]) = 1990 """); @@ -9983,7 +10017,7 @@ public override async Task Where_DateOnly_Month(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(month, [m].[Date]) = 11 """); @@ -9995,7 +10029,7 @@ public override async Task Where_DateOnly_Day(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(day, [m].[Date]) = 10 """); @@ -10007,7 +10041,7 @@ public override async Task Where_DateOnly_DayOfYear(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(dayofyear, [m].[Date]) = 314 """); @@ -10026,7 +10060,7 @@ public override async Task Where_DateOnly_AddYears(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEADD(year, CAST(3 AS int), [m].[Date]) = '1993-11-10' """); @@ -10038,7 +10072,7 @@ public override async Task Where_DateOnly_AddMonths(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEADD(month, CAST(3 AS int), [m].[Date]) = '1991-02-10' """); @@ -10050,7 +10084,7 @@ public override async Task Where_DateOnly_AddDays(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEADD(day, CAST(3 AS int), [m].[Date]) = '1990-11-13' """); @@ -10062,7 +10096,7 @@ public override async Task Where_TimeOnly_Hour(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(hour, [m].[Time]) = 10 """); @@ -10074,7 +10108,7 @@ public override async Task Where_TimeOnly_Minute(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(minute, [m].[Time]) = 15 """); @@ -10086,7 +10120,7 @@ public override async Task Where_TimeOnly_Second(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(second, [m].[Time]) = 50 """); @@ -10098,7 +10132,7 @@ public override async Task Where_TimeOnly_Millisecond(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(millisecond, [m].[Time]) = 500 """); @@ -10110,7 +10144,7 @@ public override async Task Where_TimeOnly_AddHours(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEADD(hour, CAST(3.0E0 AS int), [m].[Time]) = '13:15:50.5' """); @@ -10122,7 +10156,7 @@ public override async Task Where_TimeOnly_AddMinutes(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEADD(minute, CAST(3.0E0 AS int), [m].[Time]) = '10:18:50.5' """); @@ -10141,7 +10175,7 @@ public override async Task Where_TimeOnly_IsBetween(bool async) AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE CASE WHEN [m].[Time] >= '10:00:00' THEN CAST(1 AS bit) @@ -10664,7 +10698,7 @@ public override async Task Where_equals_method_on_nullable_with_object_overload( AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE [m].[Rating] IS NULL """); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs index 8c03bcaf770..9c46561e392 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs @@ -243,7 +243,7 @@ public override async Task Where_DateOnly_Year(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEPART(year, [m].[Date]) = 1990 """); @@ -255,7 +255,7 @@ public override async Task Where_DateOnly_Month(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEPART(month, [m].[Date]) = 11 """); @@ -267,7 +267,7 @@ public override async Task Where_DateOnly_Day(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEPART(day, [m].[Date]) = 10 """); @@ -279,7 +279,7 @@ public override async Task Where_DateOnly_DayOfYear(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEPART(dayofyear, [m].[Date]) = 314 """); @@ -298,7 +298,7 @@ public override async Task Where_DateOnly_AddYears(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEADD(year, CAST(3 AS int), [m].[Date]) = '1993-11-10' """); @@ -310,7 +310,7 @@ public override async Task Where_DateOnly_AddMonths(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEADD(month, CAST(3 AS int), [m].[Date]) = '1991-02-10' """); @@ -322,7 +322,7 @@ public override async Task Where_DateOnly_AddDays(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEADD(day, CAST(3 AS int), [m].[Date]) = '1990-11-13' """); @@ -334,7 +334,7 @@ public override async Task Where_TimeOnly_Hour(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEPART(hour, [m].[Time]) = 10 """); @@ -346,7 +346,7 @@ public override async Task Where_TimeOnly_Minute(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEPART(minute, [m].[Time]) = 15 """); @@ -358,7 +358,7 @@ public override async Task Where_TimeOnly_Second(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEPART(second, [m].[Time]) = 50 """); @@ -370,7 +370,7 @@ public override async Task Where_TimeOnly_Millisecond(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEPART(millisecond, [m].[Time]) = 500 """); @@ -382,7 +382,7 @@ public override async Task Where_TimeOnly_AddHours(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEADD(hour, CAST(3.0E0 AS int), [m].[Time]) = '13:15:50.5' """); @@ -394,7 +394,7 @@ public override async Task Where_TimeOnly_AddMinutes(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEADD(minute, CAST(3.0E0 AS int), [m].[Time]) = '10:18:50.5' """); @@ -413,7 +413,7 @@ public override async Task Where_TimeOnly_IsBetween(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE CASE WHEN [m].[Time] >= '10:00:00' THEN CAST(1 AS bit) @@ -793,7 +793,7 @@ public override async Task Where_datetimeoffset_month_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEPART(month, [m].[Timeline]) = 1 """); @@ -1104,7 +1104,7 @@ public override async Task Where_datetimeoffset_minute_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEPART(minute, [m].[Timeline]) = 0 """); @@ -2149,7 +2149,7 @@ public override async Task Where_datetimeoffset_second_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEPART(second, [m].[Timeline]) = 0 """); @@ -2827,7 +2827,7 @@ public override async Task Where_TimeSpan_Seconds(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEPART(second, [m].[Duration]) = 3 """); @@ -2929,7 +2929,7 @@ public override async Task Where_datetimeoffset_millisecond_component(bool async AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEPART(millisecond, [m].[Timeline]) = 0 """); @@ -3402,7 +3402,7 @@ public override async Task Where_TimeSpan_Hours(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEPART(hour, [m].[Duration]) = 1 """); @@ -4026,7 +4026,7 @@ public override async Task Where_datetimeoffset_utcnow(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE [m].[Timeline] <> CAST(SYSUTCDATETIME() AS datetimeoffset) """); @@ -4109,7 +4109,7 @@ public override async Task Where_datetimeoffset_now(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE [m].[Timeline] <> SYSDATETIMEOFFSET() """); @@ -4296,18 +4296,6 @@ LEFT JOIN ( """); } - public override async Task Enum_ToString_is_client_eval(bool async) - { - await base.Enum_ToString_is_client_eval(async); - - AssertSql( - """ -SELECT [g].[Rank] -FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] -ORDER BY [g].[SquadId], [g].[Nickname] -"""); - } - public override async Task Include_with_nested_navigation_in_order_by(bool async) { await base.Include_with_nested_navigation_in_order_by(async); @@ -4421,7 +4409,7 @@ public override async Task Where_datetimeoffset_dayofyear_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEPART(dayofyear, [m].[Timeline]) = 2 """); @@ -4710,6 +4698,52 @@ public override async Task Where_enum_has_flag(bool async) """); } + public override async Task ToString_enum_property_projection(bool async) + { + await base.ToString_enum_property_projection(async); + + AssertSql( + """ +SELECT CAST([g].[Rank] AS nvarchar(max)) +FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] +"""); + } + + public override async Task ToString_nullable_enum_property_projection(bool async) + { + await base.ToString_nullable_enum_property_projection(async); + + AssertSql( +""" +SELECT CAST([w].[AmmunitionType] AS nvarchar(max)) +FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] +"""); + } + + public override async Task ToString_enum_contains(bool async) + { + await base.ToString_enum_contains(async); + + AssertSql( +""" +SELECT [m].[CodeName] +FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] +WHERE CAST([m].[Difficulty] AS nvarchar(max)) LIKE N'%Med%' +"""); + } + + public override async Task ToString_nullable_enum_contains(bool async) + { + await base.ToString_nullable_enum_contains(async); + + AssertSql( +""" +SELECT [w].[Name] +FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] +WHERE CAST([w].[AmmunitionType] AS nvarchar(max)) LIKE N'%1%' +"""); + } + public override async Task Correlated_collections_naked_navigation_with_ToList(bool async) { await base.Correlated_collections_naked_navigation_with_ToList(async); @@ -5613,7 +5647,7 @@ public override async Task Where_TimeSpan_Milliseconds(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEPART(millisecond, [m].[Duration]) = 456 """); @@ -6145,7 +6179,7 @@ public override async Task Where_datetimeoffset_date_component(bool async) """ @__Date_0='0001-01-01T00:00:00.0000000' -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE CONVERT(date, [m].[Timeline]) > @__Date_0 """); @@ -6280,7 +6314,7 @@ public override async Task DateTimeOffset_Contains_Less_than_Greater_than(bool a @__end_1='1902-01-03T10:00:00.1234567+01:30' @__dates_2='["1902-01-02T10:00:00.1234567+01:30"]' (Size = 4000) -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE @__start_0 <= CAST(CONVERT(date, [m].[Timeline]) AS datetimeoffset) AND [m].[Timeline] < @__end_1 AND [m].[Timeline] IN ( SELECT [d].[value] @@ -6575,7 +6609,7 @@ public override async Task Where_datetimeoffset_year_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEPART(year, [m].[Timeline]) = 2 """); @@ -6700,7 +6734,7 @@ public override async Task Where_datetimeoffset_day_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEPART(day, [m].[Timeline]) = 2 """); @@ -6818,7 +6852,7 @@ public override async Task Where_datetimeoffset_hour_component(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEPART(hour, [m].[Timeline]) = 10 """); @@ -8606,7 +8640,7 @@ public override async Task Where_TimeSpan_Minutes(bool async) AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE DATEPART(minute, [m].[Duration]) = 2 """); @@ -9000,7 +9034,7 @@ public override async Task Where_equals_method_on_nullable_with_object_overload( AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE [m].[Rating] IS NULL """); @@ -9422,7 +9456,7 @@ public override async Task DateTimeOffset_Date_returns_datetime(bool async) """ @__dateTimeOffset_Date_0='0002-03-01T00:00:00.0000000' -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE CONVERT(date, [m].[Timeline]) >= @__dateTimeOffset_Date_0 """); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs index 50935a97d72..aed1828e67f 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs @@ -491,7 +491,7 @@ public override async Task Where_DateOnly_Year(bool async) AssertSql( """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" +SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" FROM "Missions" AS "m" WHERE CAST(strftime('%Y', "m"."Date") AS INTEGER) = 1990 """); @@ -503,7 +503,7 @@ public override async Task Where_DateOnly_Month(bool async) AssertSql( """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" +SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" FROM "Missions" AS "m" WHERE CAST(strftime('%m', "m"."Date") AS INTEGER) = 11 """); @@ -515,7 +515,7 @@ public override async Task Where_DateOnly_Day(bool async) AssertSql( """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" +SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" FROM "Missions" AS "m" WHERE CAST(strftime('%d', "m"."Date") AS INTEGER) = 10 """); @@ -527,7 +527,7 @@ public override async Task Where_DateOnly_DayOfYear(bool async) AssertSql( """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" +SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" FROM "Missions" AS "m" WHERE CAST(strftime('%j', "m"."Date") AS INTEGER) = 314 """); @@ -539,7 +539,7 @@ public override async Task Where_DateOnly_DayOfWeek(bool async) AssertSql( """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" +SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" FROM "Missions" AS "m" WHERE CAST(strftime('%w', "m"."Date") AS INTEGER) = 6 """); @@ -551,7 +551,7 @@ public override async Task Where_DateOnly_AddYears(bool async) AssertSql( """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" +SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" FROM "Missions" AS "m" WHERE date("m"."Date", CAST(3 AS TEXT) || ' years') = '1993-11-10' """); @@ -567,7 +567,7 @@ await AssertQuery( AssertSql( """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" +SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" FROM "Missions" AS "m" WHERE CAST(strftime('%Y', "m"."Date", CAST(3 AS TEXT) || ' years') AS INTEGER) = 1993 """); @@ -583,7 +583,7 @@ await AssertQuery( AssertSql( """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" +SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" FROM "Missions" AS "m" WHERE date("m"."Date", CAST(3 AS TEXT) || ' years', CAST(3 AS TEXT) || ' months') = '1994-02-10' """); @@ -595,7 +595,7 @@ public override async Task Where_DateOnly_AddMonths(bool async) AssertSql( """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" +SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" FROM "Missions" AS "m" WHERE date("m"."Date", CAST(3 AS TEXT) || ' months') = '1991-02-10' """); @@ -607,7 +607,7 @@ public override async Task Where_DateOnly_AddDays(bool async) AssertSql( """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" +SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" FROM "Missions" AS "m" WHERE date("m"."Date", CAST(3 AS TEXT) || ' days') = '1990-11-13' """); @@ -2276,18 +2276,6 @@ public override async Task Join_on_entity_qsre_keys_outer_key_is_navigation(bool """); } - public override async Task Enum_ToString_is_client_eval(bool async) - { - await base.Enum_ToString_is_client_eval(async); - - AssertSql( - """ -SELECT "g"."Rank" -FROM "Gears" AS "g" -ORDER BY "g"."SquadId", "g"."Nickname" -"""); - } - public override async Task Include_with_join_collection2(bool async) { await base.Include_with_join_collection2(async); @@ -3362,6 +3350,52 @@ public override async Task Correlated_collections_project_anonymous_collection_r """); } + public override async Task ToString_enum_property_projection(bool async) + { + await base.ToString_enum_property_projection(async); + + AssertSql( +""" +SELECT CAST("g"."Rank" AS TEXT) +FROM "Gears" AS "g" +"""); + } + + public override async Task ToString_nullable_enum_property_projection(bool async) + { + await base.ToString_nullable_enum_property_projection(async); + + AssertSql( +""" +SELECT CAST("w"."AmmunitionType" AS TEXT) +FROM "Weapons" AS "w" +"""); + } + + public override async Task ToString_enum_contains(bool async) + { + await base.ToString_enum_contains(async); + + AssertSql( +""" +SELECT "m"."CodeName" +FROM "Missions" AS "m" +WHERE instr(CAST("m"."Difficulty" AS TEXT), 'Med') > 0 +"""); + } + + public override async Task ToString_nullable_enum_contains(bool async) + { + await base.ToString_nullable_enum_contains(async); + + AssertSql( +""" +SELECT "w"."Name" +FROM "Weapons" AS "w" +WHERE "w"."AmmunitionType" IS NOT NULL AND instr(CAST("w"."AmmunitionType" AS TEXT), '1') > 0 +"""); + } + public override async Task Correlated_collections_naked_navigation_with_ToList(bool async) { await base.Correlated_collections_naked_navigation_with_ToList(async); @@ -6486,7 +6520,7 @@ public override async Task Where_equals_method_on_nullable_with_object_overload( AssertSql( """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" +SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" FROM "Missions" AS "m" WHERE "m"."Rating" IS NULL """); From 383d8a91ba0ca41796e91622c9528b250a99b078 Mon Sep 17 00:00:00 2001 From: Dane Vanderbilt Date: Sun, 12 May 2024 21:25:24 -0500 Subject: [PATCH 2/2] Fix formatting issue in SqliteObjectToStringTranslator.cs --- .../Query/Internal/SqliteObjectToStringTranslator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteObjectToStringTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteObjectToStringTranslator.cs index a1011a64a54..ed5ad247472 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteObjectToStringTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteObjectToStringTranslator.cs @@ -98,7 +98,7 @@ public SqliteObjectToStringTranslator(ISqlExpressionFactory sqlExpressionFactory _sqlExpressionFactory.Constant(true.ToString())); } - return TypeMapping.Contains(instance.Type)|| instance.Type.IsEnum + return TypeMapping.Contains(instance.Type) || instance.Type.IsEnum ? _sqlExpressionFactory.Convert(instance, typeof(string)) : null; }