From 4e796ce4589cf706755545dac27b2d61754d2819 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Thu, 24 Oct 2019 20:05:50 +0200 Subject: [PATCH] Regression test for constant projection after set operation Closes #12568 --- .../Query/SimpleQueryCosmosTest.SetOperations.cs | 1 + .../Query/SimpleQueryTestBase.SetOperations.cs | 10 ++++++++++ .../SimpleQuerySqlServerTest.SetOperations.cs | 15 +++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.SetOperations.cs b/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.SetOperations.cs index 74bf24d5c26..25fb1b33d06 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.SetOperations.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.SetOperations.cs @@ -29,6 +29,7 @@ public partial class SimpleQueryCosmosTest public override Task Union_Take_Union_Take(bool isAsync) => Task.CompletedTask; public override Task Select_Union(bool isAsync) => Task.CompletedTask; public override Task Union_Select(bool isAsync) => Task.CompletedTask; + public override Task Union_Select_scalar(bool isAsync) => Task.CompletedTask; public override Task Union_with_anonymous_type_projection(bool isAsync) => Task.CompletedTask; public override Task Select_Union_unrelated(bool isAsync) => Task.CompletedTask; public override Task Select_Union_different_fields_in_anonymous_with_subquery(bool isAsync) => Task.CompletedTask; diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.SetOperations.cs b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.SetOperations.cs index 259b32e4308..1e5b9f88af2 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.SetOperations.cs +++ b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.SetOperations.cs @@ -279,6 +279,16 @@ public virtual Task Union_Select(bool isAsync) .Where(a => a.Contains("Hanover"))); } + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Union_Select_scalar(bool isAsync) + { + return AssertQuery( + isAsync, ss => ss.Set() + .Except(ss.Set()) + .Select(c => (object)1)); + } + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Union_with_anonymous_type_projection(bool isAsync) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.SetOperations.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.SetOperations.cs index 010d8488b89..d524a32fd33 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.SetOperations.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.SetOperations.cs @@ -235,6 +235,21 @@ FROM [Customers] AS [c0] WHERE CHARINDEX(N'Hanover', [t].[Address]) > 0"); } + public override async Task Union_Select_scalar(bool isAsync) + { + await base.Union_Select_scalar(isAsync); + + AssertSql( + @"SELECT 1 +FROM ( + SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] + FROM [Customers] AS [c] + EXCEPT + SELECT [c0].[CustomerID], [c0].[Address], [c0].[City], [c0].[CompanyName], [c0].[ContactName], [c0].[ContactTitle], [c0].[Country], [c0].[Fax], [c0].[Phone], [c0].[PostalCode], [c0].[Region] + FROM [Customers] AS [c0] +) AS [t]"); + } + public override async Task Union_with_anonymous_type_projection(bool isAsync) { await base.Union_with_anonymous_type_projection(isAsync);