From dbcb0832831e6248bce1a616e36e05cfea9029f4 Mon Sep 17 00:00:00 2001 From: Smit Patel Date: Tue, 10 Sep 2019 15:05:49 -0700 Subject: [PATCH] Scrub tests Covers EFCore.Specs.Tests Query folder Resolves #8366 Resolves #8582 Resolves #8722 Resolves #9007 Resolves #9254 Resolves #12574 Resolves #12579 Resolves #12598 Resolves #12786 Resolves #12787 Resolves #12794 Resolves #12806 Resolves #12827 Resolves #12873 Resolves #14900 Resolves #15862 Resolves #16157 Resolves #17240 Close #12889 Close #17243 --- .../SimpleQueryCosmosTest.KeylessEntities.cs | 6 +- .../Query/SimpleQueryCosmosTest.cs | 9 + .../TestUtilities/TestSqlLoggerFactory.cs | 2 +- .../Query/AsyncSimpleQueryInMemoryTest.cs | 6 + .../Query/AsyncSimpleQueryTestBase.cs | 4 +- .../Query/ComplexNavigationsQueryTestBase.cs | 43 ++-- .../ComplexNavigationsWeakQueryTestBase.cs | 22 +- .../Query/FiltersTestBase.cs | 2 +- .../Query/GearsOfWarQueryTestBase.cs | 107 +++----- .../Query/GroupByQueryTestBase.cs | 20 +- .../Query/QueryNavigationsTestBase.cs | 35 +-- .../Query/SimpleQueryTestBase.Functions.cs | 8 +- .../SimpleQueryTestBase.JoinGroupJoin.cs | 2 +- .../SimpleQueryTestBase.KeylessEntities.cs | 13 +- .../SimpleQueryTestBase.ResultOperators.cs | 9 - .../SimpleQueryTestBase.SetOperations.cs | 2 +- .../Query/SimpleQueryTestBase.Where.cs | 41 --- .../Query/SimpleQueryTestBase.cs | 106 ++------ .../ProceduralQueryExpressionGenerator.cs | 88 ------- ...omplexNavigationsWeakQuerySqlServerTest.cs | 53 ++-- .../Query/FiltersSqlServerTest.cs | 26 +- .../Query/GearsOfWarQuerySqlServerTest.cs | 235 ++++++++++-------- .../Query/IncludeAsyncSqlServerTest.cs | 7 - .../SimpleQuerySqlServerTest.Functions.cs | 5 +- ...impleQuerySqlServerTest.KeylessEntities.cs | 21 +- .../Query/SimpleQuerySqlServerTest.cs | 65 ++--- .../ComplexNavigationsQuerySqliteTest.cs | 6 + .../Query/SimpleQuerySqliteTest.cs | 4 + 28 files changed, 387 insertions(+), 560 deletions(-) diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.KeylessEntities.cs b/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.KeylessEntities.cs index a4b4acc1ce9..8d818de9ab6 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.KeylessEntities.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.KeylessEntities.cs @@ -52,6 +52,7 @@ public override void KeylessEntity_with_nav_defining_query() @""); } + [ConditionalTheory(Skip = "Issue #17246")] public override async Task KeylessEntity_with_mixed_tracking(bool isAsync) { await AssertQuery( @@ -78,6 +79,7 @@ FROM root c WHERE ((c[""Discriminator""] = ""Order"") AND (c[""CustomerID""] = ""ALFKI""))"); } + [ConditionalTheory(Skip = "Issue #17246")] public override async Task KeylessEntity_with_defining_query_and_correlated_collection(bool isAsync) { await base.KeylessEntity_with_defining_query_and_correlated_collection(isAsync); @@ -88,7 +90,7 @@ FROM root c WHERE (c[""Discriminator""] = ""Customer"")"); } - [ConditionalTheory(Skip = "issue 312086")] // left join translation + [ConditionalTheory(Skip = "issue 12086")] // left join translation public override async Task KeylessEntity_select_where_navigation(bool isAsync) { await base.KeylessEntity_select_where_navigation(isAsync); @@ -96,7 +98,7 @@ public override async Task KeylessEntity_select_where_navigation(bool isAsync) AssertSql(@""); } - [ConditionalTheory(Skip = "issue 312086")] // left join translation + [ConditionalTheory(Skip = "issue 12086")] // left join translation public override async Task KeylessEntity_select_where_navigation_multi_level(bool isAsync) { await AssertQuery( diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.cs index 109d6eec3be..37561bd192f 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.cs @@ -521,6 +521,7 @@ FROM root c WHERE (c[""Discriminator""] = ""Customer"")"); } + [ConditionalTheory(Skip = "Issue #17246")] public override async Task Where_subquery_anon_nested(bool isAsync) { await base.Where_subquery_anon_nested(isAsync); @@ -1762,6 +1763,7 @@ FROM root c WHERE (c[""Discriminator""] = ""Employee"")"); } + [ConditionalTheory(Skip = "Issue #17246")] public override async Task OrderBy_multiple(bool isAsync) { await base.OrderBy_multiple(isAsync); @@ -3568,6 +3570,7 @@ FROM root c WHERE (c[""Discriminator""] = ""Customer"")"); } + [ConditionalTheory(Skip = "Issue #17246")] public override async Task Complex_nested_query_doesnt_try_binding_to_grandparent_when_parent_returns_complex_result(bool isAsync) { await base.Complex_nested_query_doesnt_try_binding_to_grandparent_when_parent_returns_complex_result(isAsync); @@ -4128,6 +4131,12 @@ public override Task OrderBy_object_type_server_evals(bool isAsync) return base.OrderBy_object_type_server_evals(isAsync); } + [ConditionalTheory(Skip = "Issue #17246")] + public override Task SelectMany_correlated_subquery_hard(bool isAsync) + { + return base.SelectMany_correlated_subquery_hard(isAsync); + } + private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/TestSqlLoggerFactory.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/TestSqlLoggerFactory.cs index ae43f0f91e8..fe1176be5e9 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/TestSqlLoggerFactory.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/TestSqlLoggerFactory.cs @@ -72,7 +72,7 @@ public void AssertBaseline(string[] expected, bool assertOrder = true) var logFile = currentDirectory.Substring( 0, currentDirectory.LastIndexOf("\\artifacts\\", StringComparison.Ordinal) + 1) - + "QueryBaseline.cs"; + + "QueryBaseline.txt"; var testInfo = testName + " : " + lineNumber + FileNewLine; diff --git a/test/EFCore.InMemory.FunctionalTests/Query/AsyncSimpleQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/AsyncSimpleQueryInMemoryTest.cs index 295108eb638..bddda8321df 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/AsyncSimpleQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/AsyncSimpleQueryInMemoryTest.cs @@ -13,5 +13,11 @@ public AsyncSimpleQueryInMemoryTest(NorthwindQueryInMemoryFixture new { Ave = c.Orders.Average(o => o.Freight) }) + c => new { Ave = c.Orders.Average(o => o.OrderID) }) .ToListAsync(); Assert.Equal(91, results.ToList().Count); diff --git a/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs index f92af02b675..09cf4e67944 100644 --- a/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs @@ -756,9 +756,8 @@ join e1 in l1s on e3.Id equals MaybeScalar( e => e.Id3 + " " + e.Id1); } - // issue #12787 - //[ConditionalTheory] - //[MemberData(nameof(IsAsyncData))] + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] public virtual Task Join_navigation_nested2(bool isAsync) { return AssertQuery( @@ -2133,7 +2132,7 @@ public virtual Task Null_protection_logic_work_for_inner_key_access_of_manually_ (e, a) => Assert.Equal(e.Id, a.Id)); } - [ConditionalTheory(Skip = "Issue#15872")] + [ConditionalTheory(Skip = "Issue#17068")] [MemberData(nameof(IsAsyncData))] public virtual Task Null_protection_logic_work_for_inner_key_access_of_manually_created_GroupJoin2(bool isAsync) { @@ -2281,7 +2280,7 @@ public virtual Task Order_by_key_of_anonymous_type_projected_navigation_doesnt_g assertOrder: true); } - [ConditionalTheory(Skip = "Issue#15872")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Optional_navigation_take_optional_navigation(bool isAsync) { @@ -2383,9 +2382,8 @@ public virtual Task SelectMany_with_Include1(bool isAsync) elementSorter: e => e.Id); } - // issue #12794 - //[ConditionalTheory] - //[MemberData(nameof(IsAsyncData))] + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] public virtual Task Orderby_SelectMany_with_Include1(bool isAsync) { return AssertIncludeQuery( @@ -3313,7 +3311,7 @@ orderby l2i.Id select new { Navigation = l2i.OneToOne_Required_FK_Inverse2, Constant = 7 }).First().Navigation.Name); } - [ConditionalTheory(Skip = "Issue #15832")] + [ConditionalTheory(Skip = "Issue #17756")] [MemberData(nameof(IsAsyncData))] public virtual Task Required_navigation_on_a_subquery_with_First_in_predicate(bool isAsync) { @@ -3641,7 +3639,7 @@ from l2_outer in grouping_outer.DefaultIfEmpty() select Maybe(l2_outer, () => l2_outer.Name)); } - [ConditionalTheory(Skip = "Issue #17068")] + [ConditionalTheory(Skip = "Issue #17328")] [MemberData(nameof(IsAsyncData))] public virtual Task GroupJoin_on_a_subquery_containing_another_GroupJoin_projecting_outer_with_client_method(bool isAsync) { @@ -3674,7 +3672,7 @@ private static Level1 ClientLevel1(Level1 arg) return arg; } - [ConditionalTheory(Skip = "Issue#15872")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task GroupJoin_on_a_subquery_containing_another_GroupJoin_projecting_inner(bool isAsync) { @@ -3702,9 +3700,8 @@ from l1_outer in grouping_outer.DefaultIfEmpty() select Maybe(l1_outer, () => l1_outer.Name)); } - // issue #12806 - //[ConditionalTheory] - //[MemberData(nameof(IsAsyncData))] + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] public virtual Task GroupJoin_on_a_subquery_containing_another_GroupJoin_with_orderby_on_inner_sequence_projecting_inner( bool isAsync) { @@ -3781,7 +3778,7 @@ private static bool ClientMethod(int? id) return true; } - [ConditionalTheory(Skip = "AlreadyFixed")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task GroupJoin_in_subquery_with_client_result_operator(bool isAsync) { @@ -3797,7 +3794,7 @@ where l1.Id < 3 select l1.Name); } - [ConditionalTheory(Skip = "Issue #17068")] + [ConditionalTheory(Skip = "Issue #17328")] [MemberData(nameof(IsAsyncData))] public virtual Task GroupJoin_in_subquery_with_client_projection(bool isAsync) { @@ -3813,7 +3810,7 @@ where l1.Id < 3 select l1.Name); } - [ConditionalTheory(Skip = "Issue #17068")] + [ConditionalTheory(Skip = "Issue #17328")] [MemberData(nameof(IsAsyncData))] public virtual Task GroupJoin_in_subquery_with_client_projection_nested1(bool isAsync) { @@ -3834,7 +3831,7 @@ where l1_outer.Id < 2 select l1_outer.Name); } - [ConditionalTheory(Skip = "Issue #17068")] + [ConditionalTheory(Skip = "Issue #17328")] [MemberData(nameof(IsAsyncData))] public virtual Task GroupJoin_in_subquery_with_client_projection_nested2(bool isAsync) { @@ -3889,7 +3886,7 @@ from l2 in groupJoin.DefaultIfEmpty() elementAsserter: (e, a) => Assert.Equal(e.Id + " " + e.client, a.Id + " " + a.client)); } - [ConditionalTheory(Skip = "Issue #17068")] + [ConditionalTheory(Skip = "Issue #17328")] [MemberData(nameof(IsAsyncData))] public virtual Task GroupJoin_client_method_in_OrderBy(bool isAsync) { @@ -4169,7 +4166,7 @@ public virtual Task Navigation_filter_navigation_grouping_ordering_by_group_key( assertOrder: true); } - [ConditionalTheory(Skip = "Issue#15872")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Nested_group_join_with_take(bool isAsync) { @@ -4368,7 +4365,7 @@ public virtual Task Select_subquery_with_client_eval_and_navigation2(bool isAsyn l2s => l2s.Select(l2 => l2s.OrderBy(l => l.Id).First().OneToOne_Required_FK_Inverse2.Name == "L1 02")); } - [ConditionalTheory(Skip = "issue #8526")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Select_subquery_with_client_eval_and_multi_level_navigation(bool isAsync) { @@ -4651,7 +4648,7 @@ public virtual Task Project_navigation_and_collection(bool isAsync) }); } - [ConditionalFact(Skip = "issue #8722")] + [ConditionalFact] public virtual void Include_inside_subquery() { using (var ctx = CreateContext()) @@ -4659,7 +4656,7 @@ public virtual void Include_inside_subquery() var query = ctx.LevelOne .Where(l1 => l1.Id < 3) .Select( - l1 => new { subquery = ctx.LevelTwo.Include(l => l.OneToMany_Optional2).Where(l => l.Id > 0) }); + l1 => new { subquery = ctx.LevelTwo.Include(l => l.OneToMany_Optional2).Where(l => l.Id > 0).ToList() }); var result = query.ToList(); } diff --git a/test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryTestBase.cs index ab47cc741af..443e942fe13 100644 --- a/test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryTestBase.cs @@ -14,24 +14,6 @@ protected ComplexNavigationsWeakQueryTestBase(TFixture fixture) { } - [ConditionalTheory(Skip = "issue #8248")] - public override Task Required_navigation_on_a_subquery_with_First_in_projection(bool isAsync) - { - return base.Required_navigation_on_a_subquery_with_First_in_projection(isAsync); - } - - [ConditionalTheory(Skip = "issue #8526")] - public override Task Select_subquery_with_client_eval_and_navigation1(bool isAsync) - { - return base.Select_subquery_with_client_eval_and_navigation1(isAsync); - } - - [ConditionalTheory(Skip = "issue #8526")] - public override Task Select_subquery_with_client_eval_and_navigation2(bool isAsync) - { - return base.Select_subquery_with_client_eval_and_navigation2(isAsync); - } - // Naked instances not supported public override Task Entity_equality_empty(bool isAsync) { @@ -180,5 +162,9 @@ public override void Member_pushdown_chain_3_levels_deep() public override void Member_pushdown_with_collection_navigation_in_the_middle() { } + + public override void Include_inside_subquery() + { + } } } diff --git a/test/EFCore.Specification.Tests/Query/FiltersTestBase.cs b/test/EFCore.Specification.Tests/Query/FiltersTestBase.cs index 913d0312519..f143e58991b 100644 --- a/test/EFCore.Specification.Tests/Query/FiltersTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/FiltersTestBase.cs @@ -140,7 +140,7 @@ public virtual void Included_one_to_many_query_with_client_eval() () => _context.Products.Include(p => p.OrderDetails).ToList()).Message)); } - [ConditionalFact(Skip = "issue #15081")] + [ConditionalFact] public virtual void Navs_query() { var results diff --git a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs index 9337d3b455f..6e7f8d6e26c 100644 --- a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs @@ -479,9 +479,8 @@ public virtual Task Include_with_join_and_inheritance1(bool isAsync) expectedIncludes); } - // issue #12827 - //[ConditionalTheory] - //[MemberData(nameof(IsAsyncData))] + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] public virtual Task Include_with_join_and_inheritance_with_orderby_before_and_after_include(bool isAsync) { var expectedIncludes = new List @@ -1101,7 +1100,7 @@ public virtual Task Select_null_propagation_optimization7(bool isAsync) gs => gs.Select(g => null != g.LeaderNickname ? g.LeaderNickname + g.LeaderNickname : null)); } - [ConditionalTheory(Skip = "issue #9201")] + [ConditionalTheory(Skip = "issue #3836")] [MemberData(nameof(IsAsyncData))] public virtual Task Select_null_propagation_optimization8(bool isAsync) { @@ -1528,7 +1527,7 @@ public virtual Task Optional_Navigation_Null_Coalesce_To_Clr_Type(bool isAsync) })); } - [ConditionalTheory(Skip = "issue #14900")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Where_subquery_boolean(bool isAsync) { @@ -1537,7 +1536,7 @@ public virtual Task Where_subquery_boolean(bool isAsync) gs => gs.Where(g => g.Weapons.OrderBy(w => w.Id).Select(w => w.IsAutomatic).FirstOrDefault())); } - [ConditionalTheory(Skip = "issue #14900")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Where_subquery_boolean_with_pushdown(bool isAsync) { @@ -1546,7 +1545,7 @@ public virtual Task Where_subquery_boolean_with_pushdown(bool isAsync) gs => gs.Where(g => g.Weapons.OrderBy(w => w.Id).FirstOrDefault().IsAutomatic)); } - [ConditionalTheory(Skip = "issue #14900")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Where_subquery_distinct_firstordefault_boolean(bool isAsync) { @@ -1555,7 +1554,7 @@ public virtual Task Where_subquery_distinct_firstordefault_boolean(bool isAsync) gs => gs.Where(g => g.HasSoulPatch && g.Weapons.Distinct().OrderBy(w => w.Id).Select(w => w.IsAutomatic).FirstOrDefault())); } - [ConditionalTheory(Skip = "issue #14900")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Where_subquery_distinct_firstordefault_boolean_with_pushdown(bool isAsync) { @@ -1609,7 +1608,7 @@ public virtual Task Where_subquery_distinct_singleordefault_boolean_with_pushdow assertOrder: true); } - [ConditionalFact(Skip = "issue #8582")] + [ConditionalFact] public virtual void Where_subquery_distinct_lastordefault_boolean() { using (var context = CreateContext()) @@ -1628,14 +1627,14 @@ public virtual void Where_subquery_distinct_lastordefault_boolean() } } - [ConditionalFact(Skip = "issue #8582")] + [ConditionalFact] public virtual void Where_subquery_distinct_last_boolean() { using (var context = CreateContext()) { var query = context.Gears .OrderBy(g => g.Nickname) - .Where(g => !g.HasSoulPatch && g.Weapons.Distinct().Last().IsAutomatic); + .Where(g => !g.HasSoulPatch && g.Weapons.Distinct().OrderBy(w => w.Id).Last().IsAutomatic); var result = query.ToList(); @@ -1644,7 +1643,7 @@ public virtual void Where_subquery_distinct_last_boolean() } } - [ConditionalTheory(Skip = "issue #14900")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Where_subquery_distinct_orderby_firstordefault_boolean(bool isAsync) { @@ -1653,7 +1652,7 @@ public virtual Task Where_subquery_distinct_orderby_firstordefault_boolean(bool gs => gs.Where(g => g.HasSoulPatch && g.Weapons.Distinct().OrderBy(w => w.Id).Select(w => w.IsAutomatic).FirstOrDefault())); } - [ConditionalTheory(Skip = "issue #14900")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Where_subquery_distinct_orderby_firstordefault_boolean_with_pushdown(bool isAsync) { @@ -1662,7 +1661,7 @@ public virtual Task Where_subquery_distinct_orderby_firstordefault_boolean_with_ gs => gs.Where(g => g.HasSoulPatch && g.Weapons.Distinct().OrderBy(w => w.Id).FirstOrDefault().IsAutomatic)); } - [ConditionalTheory(Skip = "Issue #17068")] + [ConditionalTheory(Skip = "Issue#17759")] [MemberData(nameof(IsAsyncData))] public virtual Task Where_subquery_union_firstordefault_boolean(bool isAsync) { @@ -1720,7 +1719,7 @@ public virtual Task Concat_anonymous_with_count(bool isAsync) }))); } - [ConditionalFact(Skip = "issue #9007")] + [ConditionalFact] public virtual void Concat_with_scalar_projection() { using (var context = CreateContext()) @@ -1962,9 +1961,8 @@ join t in ts on g.FullName equals Maybe(t.Gear, () => t.Gear.FullName) elementSorter: e => e.FullName); } - // issue #12786 - //[ConditionalTheory] - //[MemberData(nameof(IsAsyncData))] + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] public virtual Task Join_with_order_by_on_inner_sequence_navigation_translated_to_subquery_composite_key(bool isAsync) { return AssertQuery( @@ -2279,7 +2277,7 @@ from g2 in grouping.DefaultIfEmpty() expectedIncludes); } - [ConditionalTheory(Skip = "issue #9256")] + [ConditionalTheory(Skip = "issue #16899")] [MemberData(nameof(IsAsyncData))] public virtual Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_complex_projection_result(bool isAsync) { @@ -2372,22 +2370,28 @@ public virtual Task Optional_navigation_type_compensation_works_with_predicate_n ts => ts.Where(t => !MaybeScalar(t.Gear, () => t.Gear.HasSoulPatch) == true)); } - [ConditionalTheory(Skip = "issue #9254")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Optional_navigation_type_compensation_works_with_predicate_negated_complex1(bool isAsync) { return AssertQuery( isAsync, - ts => ts.Where(t => !(t.Gear.HasSoulPatch ? true : t.Gear.HasSoulPatch))); + ts => ts.Where(t => !(t.Gear.HasSoulPatch ? true : t.Gear.HasSoulPatch)), + ts => ts.Where(t => !(MaybeScalar(t.Gear, () => t.Gear.HasSoulPatch) == true + ? (bool?)true + : MaybeScalar(t.Gear, () => t.Gear.HasSoulPatch)) == true)); } - [ConditionalTheory(Skip = "issue #9254")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Optional_navigation_type_compensation_works_with_predicate_negated_complex2(bool isAsync) { return AssertQuery( isAsync, - ts => ts.Where(t => !(!t.Gear.HasSoulPatch ? false : t.Gear.HasSoulPatch))); + ts => ts.Where(t => !(!t.Gear.HasSoulPatch ? false : t.Gear.HasSoulPatch)), + ts => ts.Where(t => !(MaybeScalar(t.Gear, () => t.Gear.HasSoulPatch) == false + ? (bool?)false + : MaybeScalar(t.Gear, () => t.Gear.HasSoulPatch)) == true)); } [ConditionalTheory] @@ -2890,7 +2894,7 @@ public virtual void Where_datetimeoffset_milliseconds_parameter_and_constant() } } - [ConditionalTheory(Skip = "Issue #17068")] + [ConditionalTheory(Skip = "Issue #17328")] [MemberData(nameof(IsAsyncData))] public virtual Task Orderby_added_for_client_side_GroupJoin_composite_dependent_to_principal_LOJ_when_incomplete_key_is_used( bool isAsync) @@ -3487,7 +3491,7 @@ from v in Veterans(g.Reports) private string RemoveNewLines(string message) => message.Replace("\n", "").Replace("\r", ""); - [ConditionalTheory(Skip = "Issue #17068")] + [ConditionalTheory(Skip = "Issue #17328")] [MemberData(nameof(IsAsyncData))] public virtual async Task Client_method_on_collection_navigation_in_outer_join_key(bool isAsync) { @@ -3926,7 +3930,7 @@ where f is LocustHorde && o.HasSoulPatch } } - [ConditionalFact(Skip = "issue #8375")] + [ConditionalFact] public virtual void Comparing_entities_using_Equals_inheritance() { using (var ctx = CreateContext()) @@ -4367,9 +4371,8 @@ select g.Weapons.ToList(), elementAsserter: CollectionAsserter(e => e.Id, (e, a) => Assert.Equal(e.Id, a.Id))); } - // issue #12579 - //[ConditionalTheory] - //[MemberData(nameof(IsAsyncData))] + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] public virtual Task Correlated_collections_naked_navigation_with_ToList_followed_by_projecting_count(bool isAsync) { return AssertQueryScalar( @@ -5888,23 +5891,6 @@ public virtual async Task Include_with_concat(bool isAsync) RemoveNewLines(message)); } - // issue #12889 - //[ConditionalTheory] - //[MemberData(nameof(IsAsyncData))] - public virtual Task Include_collection_with_concat(bool isAsync) - { - var expectedIncludes = new List - { - new ExpectedInclude(g => g.Weapons, "Weapons"), - new ExpectedInclude(o => o.Weapons, "Weapons") - }; - - return AssertIncludeQuery( - isAsync, - gs => gs.Include(g => g.Weapons).Concat(gs), - expectedIncludes); - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Negated_bool_ternary_inside_anonymous_type_in_projection(bool isAsync) @@ -6421,7 +6407,7 @@ public class MyDTO { } - [ConditionalTheory(Skip = "issue #15862")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Select_subquery_projecting_single_constant_null_of_non_mapped_type(bool isAsync) { @@ -6435,7 +6421,7 @@ public virtual Task Select_subquery_projecting_single_constant_null_of_non_mappe })); } - [ConditionalTheory(Skip = "issue #15862")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Select_subquery_projecting_single_constant_of_non_mapped_type(bool isAsync) { @@ -6973,7 +6959,7 @@ public virtual Task Time_of_day_datetimeoffset(bool isAsync) select m.Timeline.TimeOfDay); } - [ConditionalTheory(Skip = "issue #25249")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task GroupBy_Property_Include_Select_Average(bool isAsync) { @@ -6982,7 +6968,7 @@ public virtual Task GroupBy_Property_Include_Select_Average(bool isAsync) gs => gs.Include(g => g.CityOfBirth).GroupBy(g => g.Rank).Select(g => g.Average(gg => gg.SquadId))); } - [ConditionalTheory(Skip = "issue #25249")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task GroupBy_Property_Include_Select_Sum(bool isAsync) { @@ -7044,7 +7030,7 @@ public virtual Task GroupBy_Property_Include_Aggregate_with_anonymous_selector(b assertOrder: true); } - [ConditionalTheory(Skip = "issue #12340")] + [ConditionalTheory(Skip = "issue #16752")] [MemberData(nameof(IsAsyncData))] public virtual Task Group_by_entity_key_with_include_on_that_entity_with_key_in_result_selector(bool isAsync) { @@ -7065,7 +7051,7 @@ public virtual Task Group_by_entity_key_with_include_on_that_entity_with_key_in_ }); } - [ConditionalTheory(Skip = "issue #12340")] + [ConditionalTheory(Skip = "issue #16752")] [MemberData(nameof(IsAsyncData))] public virtual Task Group_by_entity_key_with_include_on_that_entity_with_key_in_result_selector_using_EF_Property(bool isAsync) { @@ -7401,7 +7387,7 @@ public virtual void OfTypeNav3() } } - [ConditionalFact(Skip = "Issue #17234")] + [ConditionalFact(Skip = "Issue #17328")] public virtual void Nav_rewrite_Distinct_with_convert() { using (var ctx = CreateContext()) @@ -7412,7 +7398,7 @@ public virtual void Nav_rewrite_Distinct_with_convert() } } - [ConditionalFact(Skip = "Issue #17234")] + [ConditionalFact(Skip = "Issue #17328")] public virtual void Nav_rewrite_Distinct_with_convert_anonymous() { using (var ctx = CreateContext()) @@ -7553,19 +7539,6 @@ from g2 in grouping.DefaultIfEmpty() entryCount: 5); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task CrossJoin_preserves_predicate_for_inner_source(bool isAsync) - { - return AssertQuery( - isAsync, - gs => from g in gs - from o in gs.OfType() - where g.Equals(o) - orderby g.Nickname - select new { Nickname1 = g.Nickname, Nickname2 = o.Nickname }); - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Project_collection_navigation_nested_with_take_composite_key(bool isAsync) diff --git a/test/EFCore.Specification.Tests/Query/GroupByQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/GroupByQueryTestBase.cs index 37ada54d3c5..3478812ea1a 100644 --- a/test/EFCore.Specification.Tests/Query/GroupByQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/GroupByQueryTestBase.cs @@ -1857,7 +1857,7 @@ public virtual Task GroupBy_anonymous_with_where(bool isAsync) elementAsserter: GroupingAsserter(d => d.CustomerID)); } - [ConditionalTheory(Skip = "Test does not pass. See issue#7160")] + [ConditionalTheory(Skip = "Issue #17068")] [MemberData(nameof(IsAsyncData))] public virtual Task GroupBy_anonymous_subquery(bool isAsync) { @@ -2068,9 +2068,8 @@ public virtual Task GroupBy_with_orderby_take_skip_distinct(bool isAsync) entryCount: 31); } - // issue #12576 - //[ConditionalTheory] - //[MemberData(nameof(IsAsyncData))] + [ConditionalTheory(Skip = "Issue#17761")] + [MemberData(nameof(IsAsyncData))] public virtual Task GroupBy_with_orderby_take_skip_distinct_followed_by_group_key_projection(bool isAsync) { return AssertQuery( @@ -2081,9 +2080,8 @@ public virtual Task GroupBy_with_orderby_take_skip_distinct_followed_by_group_ke entryCount: 31); } - // issue #12641 - //[ConditionalTheory] - //[MemberData(nameof(IsAsyncData))] + [ConditionalTheory(Skip = "Issue #17068")] + [MemberData(nameof(IsAsyncData))] public virtual Task GroupBy_with_orderby_take_skip_distinct_followed_by_order_by_group_key(bool isAsync) { return AssertQuery( @@ -2111,14 +2109,13 @@ from orderDetail in orderJoin elementAsserter: GroupingAsserter(d => d.ProductID)); } - [ConditionalTheory(Skip = "Issue #17068")] + [ConditionalTheory(Skip = "Issue #17761")] [MemberData(nameof(IsAsyncData))] public virtual Task GroupBy_Distinct(bool isAsync) { return AssertQuery( isAsync, os => - // TODO: See issue#11215 os.GroupBy(o => o.CustomerID).Distinct().Select(g => g.Key)); } @@ -2252,9 +2249,8 @@ public virtual Task GroupBy_Select_First_GroupBy(bool isAsync) elementAsserter: GroupingAsserter(d => d.CustomerID)); } - // issue #12573 - //[ConditionalTheory] - //[MemberData(nameof(IsAsyncData))] + [ConditionalTheory(Skip = "Issue #17068")] + [MemberData(nameof(IsAsyncData))] public virtual Task GroupBy_Select_First_GroupBy_followed_by_identity_projection(bool isAsync) { return AssertQuery( diff --git a/test/EFCore.Specification.Tests/Query/QueryNavigationsTestBase.cs b/test/EFCore.Specification.Tests/Query/QueryNavigationsTestBase.cs index 985ac639703..73654a7faaf 100644 --- a/test/EFCore.Specification.Tests/Query/QueryNavigationsTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/QueryNavigationsTestBase.cs @@ -826,9 +826,8 @@ public virtual Task Collection_select_nav_prop_sum(bool isAsync) elementSorter: e => e.Sum); } - // issue #12657 - //[ConditionalTheory] - //[MemberData(nameof(IsAsyncData))] + [ConditionalTheory(Skip = "Issue#12657")] + [MemberData(nameof(IsAsyncData))] public virtual Task Collection_select_nav_prop_sum_plus_one(bool isAsync) { return AssertQuery( @@ -1156,9 +1155,8 @@ into odg entryCount: 2155); } - // issue #12816 - //[ConditionalTheory] - //[MemberData(nameof(IsAsyncData))] + [ConditionalTheory(Skip = "Issue#17068")] + [MemberData(nameof(IsAsyncData))] public virtual Task Select_anonymous_type_order_by_field_group_by_same_field(bool isAsync) { return AssertQuery( @@ -1170,31 +1168,6 @@ public virtual Task Select_anonymous_type_order_by_field_group_by_same_field(boo .Select(e => e)); } - [ConditionalTheory(Skip = "issue #6061")] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Project_first_or_default_on_empty_collection_of_value_types_returns_proper_default(bool isAsync) - { - Assert.Equal( - CoreStrings.TranslationFailed( - "(o) => ClientMethod(o.OrderID)"), - RemoveNewLines( - (await Assert.ThrowsAsync( - () => AssertQuery( - isAsync, - cs => from c in cs - where c.CustomerID.Equals("FISSA") - select new - { - c.CustomerID, OrderId = c.Orders.OrderBy(o => o.OrderID).Select(o => o.OrderID).FirstOrDefault() - }, - cs => from c in cs - select new - { - c.CustomerID, OrderId = c.Orders.OrderBy(o => o.OrderID).Select(o => o.OrderID).FirstOrDefault() - }, - elementSorter: e => e.CustomerID))).Message)); - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Project_single_scalar_value_subquery_is_properly_inlined(bool isAsync) diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Functions.cs b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Functions.cs index b40ee2185f8..ee386758eee 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Functions.cs +++ b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Functions.cs @@ -1405,16 +1405,16 @@ public virtual Task Order_by_length_twice(bool isAsync) entryCount: 91); } - // issue #12598 - //[ConditionalTheory] - //[MemberData(nameof(IsAsyncData))] + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] public virtual Task Order_by_length_twice_followed_by_projection_of_naked_collection_navigation(bool isAsync) { return AssertQuery( isAsync, cs => cs.OrderBy(c => c.CustomerID.Length).ThenBy(c => c.CustomerID.Length).ThenBy(c => c.CustomerID).Select(c => c.Orders), + assertOrder: true, elementAsserter: CollectionAsserter(o => o.OrderID, (e, a) => Assert.Equal(e.OrderID, a.OrderID)), - entryCount: 91); + entryCount: 830); } [ConditionalTheory] diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.JoinGroupJoin.cs b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.JoinGroupJoin.cs index b3b4ee83eb3..318794b78c8 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.JoinGroupJoin.cs +++ b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.JoinGroupJoin.cs @@ -68,7 +68,7 @@ from e in es entryCount: 928); } - [ConditionalTheory(Skip = "Issue #17068")] + [ConditionalTheory(Skip = "Issue #17328")] [MemberData(nameof(IsAsyncData))] public virtual Task Client_Join_select_many(bool isAsync) { diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.KeylessEntities.cs b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.KeylessEntities.cs index 9d4880fdc21..28c4c97d39b 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.KeylessEntities.cs +++ b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.KeylessEntities.cs @@ -76,17 +76,21 @@ public virtual Task KeylessEntity_with_defining_query(bool isAsync) ovs => ovs.Where(ov => ov.CustomerID == "ALFKI")); } - [ConditionalTheory(Skip = "issue #12873")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task KeylessEntity_with_defining_query_and_correlated_collection(bool isAsync) { return AssertQuery( isAsync, ovs => ovs.Where(ov => ov.CustomerID == "ALFKI").Select(ov => ov.Customer) - .Select(cv => cv.Orders.Where(cc => true).ToList())); + .OrderBy(c => c.CustomerID) + .Select(cv => cv.Orders.Where(cc => true).ToList()), + assertOrder: true, + elementAsserter: CollectionAsserter(), + entryCount: 6); } - [ConditionalTheory(Skip = "issue #15081")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task KeylessEntity_with_mixed_tracking(bool isAsync) { @@ -96,7 +100,8 @@ public virtual Task KeylessEntity_with_mixed_tracking(bool isAsync) => from c in cs from o in ovs.Where(ov => ov.CustomerID == c.CustomerID) select new { c, o }, - e => e.c.CustomerID); + e => e.c.CustomerID, + entryCount: 89); } [ConditionalTheory] diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.ResultOperators.cs b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.ResultOperators.cs index ed0960e3772..356948ec78b 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.ResultOperators.cs +++ b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.ResultOperators.cs @@ -685,15 +685,6 @@ public virtual async Task Where_OrderBy_Count_client_eval(bool isAsync) os => os.Where(o => ClientEvalPredicate(o)).OrderBy(o => ClientEvalSelectorStateless())))).Message)); } - //[ConditionalTheory] - //[MemberData(nameof(IsAsyncData))] - //public virtual Task Where_OrderBy_Count_client_eval_mixed(bool isAsync) - //{ - // return AssertCount( - // isAsync, - // os => os.Where(o => o.OrderID > 10).OrderBy(o => ClientEvalPredicate(o))); - //} - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual async Task OrderBy_Where_Count_client_eval(bool isAsync) diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.SetOperations.cs b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.SetOperations.cs index 592dcd26a1f..1aff191c843 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.SetOperations.cs +++ b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.SetOperations.cs @@ -264,7 +264,7 @@ public virtual Task Select_Union_unrelated(bool isAsync) .OrderBy(x => x), assertOrder: true); - [ConditionalTheory(Skip = "Very similar to #16298")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Select_Union_different_fields_in_anonymous_with_subquery(bool isAsync) => AssertQuery( diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Where.cs b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Where.cs index 25d1a7ec807..fa3630509c3 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Where.cs +++ b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Where.cs @@ -1660,47 +1660,6 @@ public virtual Task Where_ternary_boolean_condition_with_false_as_result_false(b .Where(p => flag ? p.UnitsInStock >= 20 : false)); } - // TODO: Re-write entity ref equality to identity equality. - // - // [ConditionalFact] - // public virtual Task Where_compare_entity_equal() - // { - // var alfki = NorthwindData.Customers.Single(c => c.CustomerID == "ALFKI"); - // - // Assert.Equal(1, - // // ReSharper disable once PossibleUnintendedReferenceComparison - // AssertQuery(cs => cs.Where(c => c == alfki))); - // } - // - // [ConditionalFact] - // public virtual Task Where_compare_entity_not_equal() - // { - // var alfki = new Customer { CustomerID = "ALFKI" }; - // - // Assert.Equal(90, - // // ReSharper disable once PossibleUnintendedReferenceComparison - // AssertQuery(cs => cs.Where(c => c != alfki))); - // - // [ConditionalFact] - // public virtual Task Project_compare_entity_equal() - // { - // var alfki = NorthwindData.Customers.Single(c => c.CustomerID == "ALFKI"); - // - // Assert.Equal(1, - // // ReSharper disable once PossibleUnintendedReferenceComparison - // AssertQuery(cs => cs.Select(c => c == alfki))); - // } - // - // [ConditionalFact] - // public virtual Task Project_compare_entity_not_equal() - // { - // var alfki = new Customer { CustomerID = "ALFKI" }; - // - // Assert.Equal(90, - // // ReSharper disable once PossibleUnintendedReferenceComparison - // AssertQuery(cs => cs.Select(c => c != alfki))); - // } - [ConditionalTheory(Skip = "Issue #14672. Cannot eval 'where (new <>f__AnonymousType409`1(x = [c].City) == { x = London })'")] [MemberData(nameof(IsAsyncData))] public virtual Task Where_compare_constructed_equal(bool isAsync) diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.cs index c471212d5bb..c184cb4f81f 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.cs @@ -324,7 +324,7 @@ public virtual Task Entity_equality_self(bool isAsync) cs => from c in cs #pragma warning disable CS1718 // Comparison made to same variable - // ReSharper disable once EqualExpressionComparison + // ReSharper disable once EqualExpressionComparison where c == c #pragma warning restore CS1718 // Comparison made to same variable select c.CustomerID); @@ -780,9 +780,8 @@ orderby o.OrderID e => e.ContactName); } - // issue #12574 - //[ConditionalTheory] - //[MemberData(nameof(IsAsyncData))] + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] public virtual Task Join_Customers_Orders_Skip_Take_followed_by_constant_projection(bool isAsync) { return AssertQuery( @@ -791,8 +790,7 @@ public virtual Task Join_Customers_Orders_Skip_Take_followed_by_constant_project (from c in cs join o in os on c.CustomerID equals o.CustomerID orderby o.OrderID - select new { c.ContactName, o.OrderID }).Skip(10).Take(5).Select(e => "Foo"), - e => e.ContactName); + select new { c.ContactName, o.OrderID }).Skip(10).Take(5).Select(e => "Foo")); } [ConditionalTheory] @@ -1434,7 +1432,7 @@ from o in os.OrderBy(oo => oo.OrderID).Take(5).Select( entryCount: 2); } - [ConditionalTheory(Skip = "Issue#16157")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Where_subquery_anon_nested(bool isAsync) { @@ -1728,7 +1726,7 @@ select os.Where(o => o.CustomerID == c.CustomerID), elementAsserter: CollectionAsserter(o => o.OrderID)); } - [ConditionalTheory(Skip = "Issue #17241")] + [ConditionalTheory(Skip = "Issue #16314")] [MemberData(nameof(IsAsyncData))] public virtual Task Select_correlated_subquery_ordered(bool isAsync) { @@ -1741,15 +1739,6 @@ select os.OrderBy(o => o.OrderID).ThenBy(o => c.CustomerID).Skip(100).Take(2), elementAsserter: CollectionAsserter()); } - // TODO: Re-linq parser - // [ConditionalFact] - // public virtual Task Select_nested_ordered_enumerable_collection() - // { - // AssertQuery(cs => - // cs.Select(c => cs.AsEnumerable().OrderBy(c2 => c2.CustomerID)), - // assertOrder: true); - // } - [ConditionalTheory(Skip = "Issue#16314")] [MemberData(nameof(IsAsyncData))] public virtual Task Select_nested_collection_in_anonymous_type(bool isAsync) @@ -2355,7 +2344,7 @@ from e in es.Where(e => e.City == c.City) entryCount: 15); } - [ConditionalTheory(Skip = "Issue #17240")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task SelectMany_correlated_subquery_hard(bool isAsync) { @@ -2425,7 +2414,7 @@ join o in os on c.CustomerID equals o.CustomerID select c)); } - [ConditionalTheory(Skip = "TaskItem#6")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Where_Join_Any(bool isAsync) { @@ -2434,7 +2423,7 @@ public virtual Task Where_Join_Any(bool isAsync) cs => cs.Where(c => c.CustomerID == "ALFKI" && c.Orders.Any(o => o.OrderDate == new DateTime(2008, 10, 24)))); } - [ConditionalTheory(Skip = "TaskItem#6")] + [ConditionalTheory(Skip = "Issue#17762")] [MemberData(nameof(IsAsyncData))] public virtual Task Where_Join_Exists(bool isAsync) { @@ -2443,7 +2432,7 @@ public virtual Task Where_Join_Exists(bool isAsync) cs => cs.Where(c => c.CustomerID == "ALFKI" && c.Orders.Exists(o => o.OrderDate == new DateTime(2008, 10, 24)))); } - [ConditionalTheory(Skip = "TaskItem#6")] + [ConditionalTheory(Skip = "Issue#17762")] [MemberData(nameof(IsAsyncData))] public virtual Task Where_Join_Exists_Inequality(bool isAsync) { @@ -2453,7 +2442,7 @@ public virtual Task Where_Join_Exists_Inequality(bool isAsync) entryCount: 1); } - [ConditionalTheory(Skip = "TaskItem#6")] + [ConditionalTheory(Skip = "Issue#17762")] [MemberData(nameof(IsAsyncData))] public virtual Task Where_Join_Exists_Constant(bool isAsync) { @@ -2462,7 +2451,7 @@ public virtual Task Where_Join_Exists_Constant(bool isAsync) cs => cs.Where(c => c.CustomerID == "ALFKI" && c.Orders.Exists(o => false))); } - [ConditionalTheory(Skip = "TaskItem#6")] + [ConditionalTheory(Skip = "Issue#17762")] [MemberData(nameof(IsAsyncData))] public virtual Task Where_Join_Not_Exists(bool isAsync) { @@ -2725,35 +2714,6 @@ from o in os select c); } - // TODO: Composite keys, slow.. - - // [ConditionalFact] - // public virtual Task Multiple_joins_with_join_conditions_in_where() - // { - // AssertQuery((cs, os, ods) => - // from c in cs - // from o in os.OrderBy(o1 => o1.OrderID).Take(10) - // from od in ods - // where o.CustomerID == c.CustomerID - // && o.OrderID == od.OrderID - // where c.CustomerID == "ALFKI" - // select od.ProductID, - // assertOrder: true); - // } - // [ConditionalFact] - // - // public virtual Task TestMultipleJoinsWithMissingJoinCondition() - // { - // AssertQuery((cs, os, ods) => - // from c in cs - // from o in os - // from od in ods - // where o.CustomerID == c.CustomerID - // where c.CustomerID == "ALFKI" - // select od.ProductID - // ); - // } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task OrderBy(bool isAsync) @@ -2922,16 +2882,17 @@ public virtual Task OrderBy_Select(bool isAsync) assertOrder: true); } - [ConditionalTheory(Skip = "OrderByOrderBy should ignore inner ordering")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task OrderBy_multiple(bool isAsync) { return AssertQuery( isAsync, - cs => - cs.OrderBy(c => c.CustomerID) + cs => cs.Where(c => c.CustomerID.StartsWith("A")) + .OrderBy(c => c.CustomerID) // ReSharper disable once MultipleOrderBy .OrderBy(c => c.Country) + .ThenBy(c => c.City) .Select(c => c.City), assertOrder: true); } @@ -3423,22 +3384,7 @@ public virtual void Can_cast_CreateQuery_result_to_IQueryable_T_bug_1730() } } - //[ConditionalFact] - //public virtual void Can_execute_non_generic() - //{ - // using (var context = CreateContext()) - // { - // IQueryable products = context.Products; - - // Assert.NotNull( - // products.Provider.Execute( - // Expression.Call( - // new LinqOperatorProvider().First.MakeGenericMethod(typeof(Product)), - // products.Expression))); - // } - //} - - [ConditionalFact(Skip = "Issue #17242")] + [ConditionalFact(Skip = "Issue #16314")] public virtual void Select_Subquery_Single() { using (var context = CreateContext()) @@ -3514,7 +3460,7 @@ public virtual void Select_Where_Subquery_Equality() { var orders = (from o in context.Orders.OrderBy(o => o.OrderID).Take(1) - // ReSharper disable once UseMethodAny.0 + // ReSharper disable once UseMethodAny.0 where (from od in context.OrderDetails.OrderBy(od => od.OrderID).Take(2) where (from c in context.Set() where c.CustomerID == o.CustomerID @@ -4519,7 +4465,7 @@ from e2 in grouping.DefaultIfEmpty() e => e.City1 + " " + e.City2); } - [ConditionalTheory(Skip = "Issue #17068")] + [ConditionalTheory(Skip = "Issue #17328")] [MemberData(nameof(IsAsyncData))] public virtual Task No_orderby_added_for_client_side_GroupJoin_dependent_to_principal_LOJ(bool isAsync) { @@ -4535,7 +4481,7 @@ from c in ClientDefaultIfEmpty(grouping) e => e.Id1 + " " + e.Id2); } - [ConditionalTheory(Skip = "Issue #17068")] + [ConditionalTheory(Skip = "Issue #17328")] [MemberData(nameof(IsAsyncData))] public virtual Task No_orderby_added_for_client_side_GroupJoin_dependent_to_principal_LOJ_with_additional_join_condition1( bool isAsync) @@ -4552,7 +4498,7 @@ from c in ClientDefaultIfEmpty(grouping) e => e.Id1 + " " + e.Id2); } - [ConditionalTheory(Skip = "Issue #17068")] + [ConditionalTheory(Skip = "Issue #17328")] [MemberData(nameof(IsAsyncData))] public virtual Task No_orderby_added_for_client_side_GroupJoin_dependent_to_principal_LOJ_with_additional_join_condition2( bool isAsync) @@ -4569,7 +4515,7 @@ from c in ClientDefaultIfEmpty(grouping) e => e.Id1 + " " + e.Id2); } - [ConditionalTheory(Skip = "Issue #17068")] + [ConditionalTheory(Skip = "Issue #17328")] [MemberData(nameof(IsAsyncData))] public virtual Task Orderby_added_for_client_side_GroupJoin_principal_to_dependent_LOJ(bool isAsync) { @@ -5295,7 +5241,7 @@ from c2 in cs2 e => e.Id1 + " " + e.Id2); } - [ConditionalTheory(Skip = "issue #8366")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Compare_two_collection_navigations_using_equals(bool isAsync) { @@ -5354,7 +5300,7 @@ public virtual Task OrderBy_OrderBy_same_column_different_direction(bool isAsync assertOrder: true); } - [ConditionalTheory(Skip = "Complex Query")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Complex_nested_query_doesnt_try_binding_to_grandparent_when_parent_returns_complex_result(bool isAsync) { @@ -5402,7 +5348,7 @@ public virtual Task OrderBy_Dto_projection_skip_take(bool isAsync) elementSorter: e => e.Id); } - [ConditionalFact(Skip = "Issue #17243")] + [ConditionalFact(Skip = "Issue #16314")] public virtual void Streaming_chained_sync_query() { using (var context = CreateContext()) @@ -5626,7 +5572,7 @@ public virtual Task Collection_navigation_equal_to_null_for_subquery(bool isAsyn entryCount: 2); } - [ConditionalTheory(Skip = "Needs AsQueryable")] + [ConditionalTheory(Skip = "Issue#17756")] [MemberData(nameof(IsAsyncData))] public virtual Task Dependent_to_principal_navigation_equal_to_null_for_subquery(bool isAsync) { diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/ProceduralQueryExpressionGenerator.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/ProceduralQueryExpressionGenerator.cs index 2f28aca0d6c..831d3feaceb 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/ProceduralQueryExpressionGenerator.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/ProceduralQueryExpressionGenerator.cs @@ -130,17 +130,6 @@ static ProcedurallyGeneratedQueryExecutor() AddExpectedFailure("GroupBy_aggregate_Pushdown", "Invalid column name 'c'."); // 12569 AddExpectedFailure("GroupBy_with_orderby_take_skip_distinct", "Invalid column name 'c'."); // 12569 - AddExpectedFailure( - "GroupBy_Select_First_GroupBy", - "Query source (from Customer c in [g]) has already been associated with an expression."); // 12573 - - AddExpectedFailure("Join_Customers_Orders_Skip_Take", "Object reference not set to an instance of an object."); // 12574 - AddExpectedFailure( - "Join_Customers_Orders_Projection_With_String_Concat_Skip_Take", - "Object reference not set to an instance of an object."); // 12574 - AddExpectedFailure( - "Join_Customers_Orders_Orders_Skip_Take_Same_Properties", "Object reference not set to an instance of an object."); // 12574 - AddExpectedFailure( "SelectMany_navigation_property", "The property '' on entity type 'Level2' could not be found. Ensure that the property exists and has been included in the model."); // 12575 @@ -166,15 +155,6 @@ static ProcedurallyGeneratedQueryExecutor() "Multiple_SelectMany_calls", "The property '' on entity type 'Level3' could not be found. Ensure that the property exists and has been included in the model."); // 12575 - AddExpectedFailure( - "GroupBy_with_orderby_take_skip_distinct", - "Unable to cast object of type 'Remotion.Linq.Clauses.ResultOperators.DistinctResultOperator' to type 'Remotion.Linq.Clauses.ResultOperators.GroupResultOperator'."); // 12576 - AddExpectedFailure( - "GroupBy_Distinct", - "Unable to cast object of type 'Remotion.Linq.Clauses.ResultOperators.DistinctResultOperator' to type 'Remotion.Linq.Clauses.ResultOperators.GroupResultOperator'."); // 12576 - - AddExpectedFailure("Correlated_collections_naked_navigation_with_ToList", "Rewriting child expression from type"); // 12579 - AddExpectedFailure( "Project_single_element_from_collection_with_OrderBy_Distinct_and_FirstOrDefault", "Only one expression can be specified in the select list when the subquery is not introduced with EXISTS."); // 12580 @@ -197,14 +177,6 @@ static ProcedurallyGeneratedQueryExecutor() "Project_single_element_from_collection_with_OrderBy_Take_and_FirstOrDefault", "Object reference not set to an instance of an object."); // 12597 - AddExpectedFailure( - "Order_by_length_twice", - "Unable to cast object of type 'System.Linq.Expressions.PropertyExpression' to type 'Remotion.Linq.Clauses.Expressions.QuerySourceReferenceExpression'."); // 12598 - - AddExpectedFailure( - "GroupBy_Shadow3", - "Column 'Employees.Title' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."); // 12598 - AddExpectedFailure("GroupBy_Shadow", "Unable to cast object of type 'System.String' to type"); // 12601 AddExpectedFailure( "Collection_select_nav_prop_first_or_default_then_nav_prop_nested_using_property_method", @@ -214,8 +186,6 @@ static ProcedurallyGeneratedQueryExecutor() AddExpectedFailure("GroupBy_Shadow3", "Value does not fall within the expected range."); // 12640 AddExpectedFailure("GroupBy_SelectMany", "Value does not fall within the expected range."); // 12640 - AddExpectedFailure("GroupBy_with_orderby_take_skip_distinct", "_TrackGroupedEntities"); // 12641 - AddExpectedFailure( "Select_collection_navigation_simple", "Index was out of range. Must be non-negative and less than the size of the collection."); // 12643 @@ -244,32 +214,6 @@ static ProcedurallyGeneratedQueryExecutor() AddExpectedFailure("Simple_owned_level1_level2_GroupBy_Having_Count", "Incorrect syntax near '+'."); // 12658 - AddExpectedFailure("Join_navigation_translated_to_subquery_composite_key", "Invalid column name 'Note'."); // 12786 - AddExpectedFailure("Join_on_entity_qsre_keys_inner_key_is_navigation_composite_key", "Invalid column name 'Note'."); // 12786 - AddExpectedFailure("Join_on_entity_qsre_keys_inner_key_is_navigation", "Invalid column name 'Nickname'."); // 12786 - AddExpectedFailure("Client_method_on_collection_navigation_in_outer_join_key", "Invalid column name 'Nickname'."); // 12786 - - AddExpectedFailure( - "Join_navigation_translated_to_subquery_deeply_nested_non_key_join", "Parameter name: tableExpression"); // 12787 - AddExpectedFailure("Join_on_entity_qsre_keys_inner_key_is_nested_navigation", "Parameter name: tableExpression"); // 12787 - AddExpectedFailure("Join_navigation_translated_to_subquery_deeply_nested_required", "Parameter name: tableExpression"); // 12787 - AddExpectedFailure("Join_navigation_translated_to_subquery_nested", "Parameter name: tableExpression"); // 12787 - AddExpectedFailure("Query_source_materialization_bug_4547", "Parameter name: tableExpression"); // 12787 - AddExpectedFailure("GroupJoin_with_complex_subquery_and_LOJ_gets_flattened", "Parameter name: tableExpression"); // 12787 - AddExpectedFailure("GroupJoin_with_complex_subquery_and_LOJ_gets_flattened2", "Parameter name: tableExpression"); // 12787 - - AddExpectedFailure("SelectMany_with_Include1", "must be reducible node"); // 12794 - AddExpectedFailure("Multiple_SelectMany_with_Include", "must be reducible node"); // 12794 - AddExpectedFailure("SelectMany_with_Include_ThenInclude", "must be reducible node"); // 12794 - AddExpectedFailure("Include_after_SelectMany_and_reference_navigation", "must be reducible node"); // 12794 - AddExpectedFailure("Include_after_multiple_SelectMany_and_reference_navigation", "must be reducible node"); // 12794 - AddExpectedFailure("Include_after_SelectMany_and_multiple_reference_navigations", "must be reducible node"); // 12794 - AddExpectedFailure("Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result4", "must be reducible node"); // 12794 - AddExpectedFailure("Include_with_join_collection2", "must be reducible node"); // 12794 - AddExpectedFailure("Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_conditional_result", "must be reducible node"); // 12794 - AddExpectedFailure("Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result3", "must be reducible node"); // 12794 - AddExpectedFailure("Include_with_join_and_inheritance3", "must be reducible node"); // 12794 - AddExpectedFailure("Join_GroupBy_Aggregate", "must be reducible node"); // 12799 AddExpectedFailure("GroupJoin_GroupBy_Aggregate_2", "must be reducible node"); // 12799 AddExpectedFailure("GroupJoin_GroupBy_Aggregate_3", "must be reducible node"); // 12799 @@ -306,14 +250,6 @@ static ProcedurallyGeneratedQueryExecutor() AddExpectedFailure("GroupJoin_complex_GroupBy_Aggregate", "Value does not fall within the expected range."); // 12805 AddExpectedFailure("OrderBy_GroupBy_SelectMany", "Value does not fall within the expected range."); // 12805 - AddExpectedFailure( - "GroupJoin_on_a_subquery_containing_another_GroupJoin_projecting_inner", - "Invalid column name 'Level1_Optional_Id'."); // 12806 - - AddExpectedFailure( - "Let_group_by_nav_prop", - "A column has been specified more than once in the order by list. Columns in the order by list must be unique."); // 12816 - AddExpectedFailure( "Select_expression_references_are_updated_correctly_with_subquery", "The conversion of a varchar data type to a datetime data type resulted in an out-of-range value."); // 12819 @@ -382,10 +318,6 @@ static ProcedurallyGeneratedQueryExecutor() "Parameter_extraction_short_circuits_3", "An exception was thrown while attempting to evaluate the LINQ query parameter expression"); // 12820 - AddExpectedFailure("Include_with_join_reference2", "Invalid column name '"); // 12827 - AddExpectedFailure("Include_with_join_and_inheritance1", "Invalid column name '"); // 12827 - AddExpectedFailure("Include_with_join_and_inheritance3", "Invalid column name '"); // 12827 - AddExpectedFailure( "Entity_equality_local", "has already been declared. Variable names must be unique within a query batch or stored procedure."); // 12871 @@ -393,29 +325,9 @@ static ProcedurallyGeneratedQueryExecutor() "Where_poco_closure", "has already been declared. Variable names must be unique within a query batch or stored procedure."); // 12871 - AddExpectedFailure("QueryType_with_defining_query", "Object reference not set to an instance of an object."); // 12873 - AddExpectedFailure( "QueryType_with_included_navs_multi_level", "Object reference not set to an instance of an object."); // 12874 - AddExpectedFailure( - "Include_with_concat", - ", but it has items of type 'Microsoft.EntityFrameworkCore.Query.Internal.AnonymousObject'."); // 12889 - AddExpectedFailure( - "Concat_with_groupings", - ", but it has items of type 'Microsoft.EntityFrameworkCore.Query.Internal.AnonymousObject'."); // 12889 - AddExpectedFailure( - "Union_dbset", ", but it has items of type 'Microsoft.EntityFrameworkCore.Query.Internal.AnonymousObject'."); // 12889 - AddExpectedFailure( - "Concat_nested", ", but it has items of type 'Microsoft.EntityFrameworkCore.Query.Internal.AnonymousObject'."); // 12889 - AddExpectedFailure( - "Union_simple", ", but it has items of type 'Microsoft.EntityFrameworkCore.Query.Internal.AnonymousObject'."); // 12889 - AddExpectedFailure( - "Union_nested", ", but it has items of type 'Microsoft.EntityFrameworkCore.Query.Internal.AnonymousObject'."); // 12889 - AddExpectedFailure( - "Where_subquery_concat_order_by_firstordefault_boolean", - ", but it has items of type 'Microsoft.EntityFrameworkCore.Query.Internal.AnonymousObject'."); // 12889 - AddExpectedFailure("Select_null_propagation_negative1", "Specified cast is not valid."); // 12958 AddExpectedFailure("Select_null_propagation_negative2", "Specified cast is not valid."); // 12958 AddExpectedFailure("Select_null_propagation_negative3", "Specified cast is not valid."); // 12958 diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerTest.cs index f3cdd8e3da3..21f904d528a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerTest.cs @@ -172,30 +172,45 @@ public override async Task Nested_group_join_with_take(bool isAsync) SELECT [t5].[Level2_Name] FROM ( - SELECT TOP(@__p_0) [t1].* - FROM [Level1] AS [l1_inner] + SELECT TOP(@__p_0) [t1].[Id], [t1].[OneToOne_Required_PK_Date], [t1].[Level1_Optional_Id], [t1].[Level1_Required_Id], [t1].[Level2_Name], [t1].[OneToMany_Optional_Inverse2Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[OneToOne_Optional_PK_Inverse2Id], [l].[Id] AS [Id0] + FROM [Level1] AS [l] LEFT JOIN ( - SELECT [t0].[Id], [t0].[OneToOne_Required_PK_Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Level2_Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id] - FROM [Level1] AS [t] + SELECT [l0].[Id], [l0].[Date], [l0].[Name], [t].[Id] AS [Id0], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id] + FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [t.OneToOne_Required_PK1].* - FROM [Level1] AS [t.OneToOne_Required_PK1] - WHERE [t.OneToOne_Required_PK1].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([t.OneToOne_Required_PK1].[Level1_Required_Id] IS NOT NULL AND [t.OneToOne_Required_PK1].[OneToOne_Required_PK_Date] IS NOT NULL) - ) AS [t0] ON [t].[Id] = [t0].[Id] - WHERE [t0].[Id] IS NOT NULL - ) AS [t1] ON [l1_inner].[Id] = [t1].[Level1_Optional_Id] - ORDER BY [l1_inner].[Id] + SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Level2_Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l2].[Id] AS [Id0] + FROM [Level1] AS [l1] + INNER JOIN [Level1] AS [l2] ON [l1].[Id] = [l2].[Id] + WHERE [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToOne_Required_PK_Date] IS NOT NULL) + ) AS [t] ON [l0].[Id] = [t].[Id] + WHERE [t].[Id] IS NOT NULL + ) AS [t0] ON [l].[Id] = [t0].[Level1_Optional_Id] + LEFT JOIN ( + SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Level2_Name], [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id], [l4].[Id] AS [Id0] + FROM [Level1] AS [l3] + INNER JOIN [Level1] AS [l4] ON [l3].[Id] = [l4].[Id] + WHERE [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToOne_Required_PK_Date] IS NOT NULL) + ) AS [t1] ON [t0].[Id] = [t1].[Id] + ORDER BY [l].[Id] ) AS [t2] LEFT JOIN ( - SELECT [t4].* - FROM [Level1] AS [t3] + SELECT [l5].[Id], [l5].[Date], [l5].[Name], [t3].[Id] AS [Id0], [t3].[OneToOne_Required_PK_Date], [t3].[Level1_Optional_Id], [t3].[Level1_Required_Id], [t3].[Level2_Name], [t3].[OneToMany_Optional_Inverse2Id], [t3].[OneToMany_Required_Inverse2Id], [t3].[OneToOne_Optional_PK_Inverse2Id] + FROM [Level1] AS [l5] LEFT JOIN ( - SELECT [t.OneToOne_Required_PK10].* - FROM [Level1] AS [t.OneToOne_Required_PK10] - WHERE [t.OneToOne_Required_PK10].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([t.OneToOne_Required_PK10].[Level1_Required_Id] IS NOT NULL AND [t.OneToOne_Required_PK10].[OneToOne_Required_PK_Date] IS NOT NULL) - ) AS [t4] ON [t3].[Id] = [t4].[Id] - WHERE [t4].[Id] IS NOT NULL -) AS [t5] ON [t2].[Id] = [t5].[Level1_Optional_Id]"); + SELECT [l6].[Id], [l6].[OneToOne_Required_PK_Date], [l6].[Level1_Optional_Id], [l6].[Level1_Required_Id], [l6].[Level2_Name], [l6].[OneToMany_Optional_Inverse2Id], [l6].[OneToMany_Required_Inverse2Id], [l6].[OneToOne_Optional_PK_Inverse2Id], [l7].[Id] AS [Id0] + FROM [Level1] AS [l6] + INNER JOIN [Level1] AS [l7] ON [l6].[Id] = [l7].[Id] + WHERE [l6].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l6].[Level1_Required_Id] IS NOT NULL AND [l6].[OneToOne_Required_PK_Date] IS NOT NULL) + ) AS [t3] ON [l5].[Id] = [t3].[Id] + WHERE [t3].[Id] IS NOT NULL +) AS [t4] ON [t2].[Id] = [t4].[Level1_Optional_Id] +LEFT JOIN ( + SELECT [l8].[Id], [l8].[OneToOne_Required_PK_Date], [l8].[Level1_Optional_Id], [l8].[Level1_Required_Id], [l8].[Level2_Name], [l8].[OneToMany_Optional_Inverse2Id], [l8].[OneToMany_Required_Inverse2Id], [l8].[OneToOne_Optional_PK_Inverse2Id], [l9].[Id] AS [Id0] + FROM [Level1] AS [l8] + INNER JOIN [Level1] AS [l9] ON [l8].[Id] = [l9].[Id] + WHERE [l8].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l8].[Level1_Required_Id] IS NOT NULL AND [l8].[OneToOne_Required_PK_Date] IS NOT NULL) +) AS [t5] ON [t4].[Id] = [t5].[Id] +ORDER BY [t2].[Id0]"); } public override async Task Explicit_GroupJoin_in_subquery_with_unrelated_projection2(bool isAsync) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/FiltersSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/FiltersSqlServerTest.cs index b3a1601ba10..54b241f7cc4 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/FiltersSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/FiltersSqlServerTest.cs @@ -187,23 +187,27 @@ public override void Navs_query() base.Navs_query(); AssertSql( - @"@__ef_filter___quantity_1='50' (DbType = Int16) -@__ef_filter__TenantPrefix_0='B' (Size = 4000) + @"@__ef_filter__TenantPrefix_0='B' (Size = 4000) +@__ef_filter___quantity_1='50' 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] INNER JOIN ( - SELECT [o].* + SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] - LEFT JOIN [Customers] AS [o.Customer] ON [o].[CustomerID] = [o.Customer].[CustomerID] - WHERE [o.Customer].[CompanyName] IS NOT NULL -) AS [t] ON [c].[CustomerID] = [t].[CustomerID] + LEFT JOIN ( + 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] + WHERE ((@__ef_filter__TenantPrefix_0 = N'') AND @__ef_filter__TenantPrefix_0 IS NOT NULL) OR ([c0].[CompanyName] IS NOT NULL AND (@__ef_filter__TenantPrefix_0 IS NOT NULL AND (([c0].[CompanyName] LIKE [c0].[CompanyName] + N'%') AND (((LEFT([c0].[CompanyName], LEN(@__ef_filter__TenantPrefix_0)) = @__ef_filter__TenantPrefix_0) AND (LEFT([c0].[CompanyName], LEN(@__ef_filter__TenantPrefix_0)) IS NOT NULL AND @__ef_filter__TenantPrefix_0 IS NOT NULL)) OR (LEFT([c0].[CompanyName], LEN(@__ef_filter__TenantPrefix_0)) IS NULL AND @__ef_filter__TenantPrefix_0 IS NULL))))) + ) AS [t] ON [o].[CustomerID] = [t].[CustomerID] + WHERE [t].[CompanyName] IS NOT NULL +) AS [t0] ON [c].[CustomerID] = [t0].[CustomerID] INNER JOIN ( - SELECT [od].* - FROM [Order Details] AS [od] - WHERE [od].[Quantity] > @__ef_filter___quantity_1 -) AS [t0] ON [t].[OrderID] = [t0].[OrderID] -WHERE (([c].[CompanyName] LIKE @__ef_filter__TenantPrefix_0 + N'%' AND (LEFT([c].[CompanyName], LEN(@__ef_filter__TenantPrefix_0)) = @__ef_filter__TenantPrefix_0)) OR (@__ef_filter__TenantPrefix_0 = N'')) AND ([t0].[Discount] < CAST(10 AS real))"); + SELECT [o0].[OrderID], [o0].[ProductID], [o0].[Discount], [o0].[Quantity], [o0].[UnitPrice] + FROM [Order Details] AS [o0] + WHERE [o0].[Quantity] > @__ef_filter___quantity_1 +) AS [t1] ON [t0].[OrderID] = [t1].[OrderID] +WHERE (((@__ef_filter__TenantPrefix_0 = N'') AND @__ef_filter__TenantPrefix_0 IS NOT NULL) OR ([c].[CompanyName] IS NOT NULL AND (@__ef_filter__TenantPrefix_0 IS NOT NULL AND (([c].[CompanyName] LIKE [c].[CompanyName] + N'%') AND (((LEFT([c].[CompanyName], LEN(@__ef_filter__TenantPrefix_0)) = @__ef_filter__TenantPrefix_0) AND (LEFT([c].[CompanyName], LEN(@__ef_filter__TenantPrefix_0)) IS NOT NULL AND @__ef_filter__TenantPrefix_0 IS NOT NULL)) OR (LEFT([c].[CompanyName], LEN(@__ef_filter__TenantPrefix_0)) IS NULL AND @__ef_filter__TenantPrefix_0 IS NULL)))))) AND ([t1].[Discount] < CAST(10 AS real))"); } [ConditionalFact] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs index 63049538503..4ea4217cfa8 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs @@ -291,7 +291,19 @@ public override async Task Include_with_join_and_inheritance_with_orderby_before await base.Include_with_join_and_inheritance_with_orderby_before_and_after_include(isAsync); AssertSql( - ""); + @"SELECT [t0].[Nickname], [t0].[SquadId], [t0].[AssignedCityName], [t0].[CityOrBirthName], [t0].[Discriminator], [t0].[FullName], [t0].[HasSoulPatch], [t0].[LeaderNickname], [t0].[LeaderSquadId], [t0].[Rank], [t].[Id], [t1].[Nickname], [t1].[SquadId], [t1].[AssignedCityName], [t1].[CityOrBirthName], [t1].[Discriminator], [t1].[FullName], [t1].[HasSoulPatch], [t1].[LeaderNickname], [t1].[LeaderSquadId], [t1].[Rank] +FROM [Tags] AS [t] +INNER JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOrBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] + FROM [Gears] AS [g] + WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND ([g].[Discriminator] = N'Officer') +) AS [t0] ON (([t].[GearSquadId] = [t0].[SquadId]) AND [t].[GearSquadId] IS NOT NULL) AND (([t].[GearNickName] = [t0].[Nickname]) AND [t].[GearNickName] IS NOT NULL) +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOrBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] + FROM [Gears] AS [g0] + WHERE [g0].[Discriminator] IN (N'Gear', N'Officer') +) AS [t1] ON (([t0].[Nickname] = [t1].[LeaderNickname]) AND [t1].[LeaderNickname] IS NOT NULL) AND ([t0].[SquadId] = [t1].[LeaderSquadId]) +ORDER BY [t0].[HasSoulPatch], [t].[Id], [t0].[Nickname], [t0].[SquadId], [t1].[Nickname], [t1].[SquadId]"); } public override async Task Include_with_join_and_inheritance2(bool isAsync) @@ -1374,12 +1386,11 @@ public override async Task Where_subquery_boolean(bool isAsync) AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOrBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] -WHERE [g].[Discriminator] IN (N'Officer', N'Gear') AND (COALESCE(( +WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND (( SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id] -), CAST(0 AS bit)) = CAST(1 AS bit))"); + WHERE ([g].[FullName] = [w].[OwnerFullName]) AND [w].[OwnerFullName] IS NOT NULL + ORDER BY [w].[Id]) = CAST(1 AS bit))"); } public override async Task Where_subquery_boolean_with_pushdown(bool isAsync) @@ -1389,12 +1400,11 @@ public override async Task Where_subquery_boolean_with_pushdown(bool isAsync) AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOrBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] -WHERE [g].[Discriminator] IN (N'Officer', N'Gear') AND (( +WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND (( SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id] -) = CAST(1 AS bit))"); + WHERE ([g].[FullName] = [w].[OwnerFullName]) AND [w].[OwnerFullName] IS NOT NULL + ORDER BY [w].[Id]) = CAST(1 AS bit))"); } public override async Task Where_subquery_distinct_firstordefault_boolean(bool isAsync) @@ -1404,15 +1414,14 @@ public override async Task Where_subquery_distinct_firstordefault_boolean(bool i AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOrBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] -WHERE [g].[Discriminator] IN (N'Officer', N'Gear') AND (([g].[HasSoulPatch] = CAST(1 AS bit)) AND (COALESCE(( +WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND (([g].[HasSoulPatch] = CAST(1 AS bit)) AND (( SELECT TOP(1) [t].[IsAutomatic] FROM ( - SELECT DISTINCT [w].* + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] + WHERE ([g].[FullName] = [w].[OwnerFullName]) AND [w].[OwnerFullName] IS NOT NULL ) AS [t] - ORDER BY [t].[Id] -), CAST(0 AS bit)) = CAST(1 AS bit)))"); + ORDER BY [t].[Id]) = CAST(1 AS bit)))"); } public override async Task Where_subquery_distinct_firstordefault_boolean_with_pushdown(bool isAsync) @@ -1422,15 +1431,14 @@ public override async Task Where_subquery_distinct_firstordefault_boolean_with_p AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOrBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] -WHERE [g].[Discriminator] IN (N'Officer', N'Gear') AND (([g].[HasSoulPatch] = CAST(1 AS bit)) AND (( +WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND (([g].[HasSoulPatch] = CAST(1 AS bit)) AND (( SELECT TOP(1) [t].[IsAutomatic] FROM ( - SELECT DISTINCT [w].* + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] + WHERE ([g].[FullName] = [w].[OwnerFullName]) AND [w].[OwnerFullName] IS NOT NULL ) AS [t] - ORDER BY [t].[Id] -) = CAST(1 AS bit)))"); + ORDER BY [t].[Id]) = CAST(1 AS bit)))"); } public override async Task Where_subquery_distinct_first_boolean(bool isAsync) @@ -1504,7 +1512,17 @@ public override void Where_subquery_distinct_lastordefault_boolean() base.Where_subquery_distinct_lastordefault_boolean(); AssertSql( - ""); + @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOrBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +FROM [Gears] AS [g] +WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND (( + SELECT TOP(1) [t].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE ([g].[FullName] = [w].[OwnerFullName]) AND [w].[OwnerFullName] IS NOT NULL + ) AS [t] + ORDER BY [t].[Id] DESC) <> CAST(1 AS bit)) +ORDER BY [g].[Nickname]"); } public override void Where_subquery_distinct_last_boolean() @@ -1512,7 +1530,17 @@ public override void Where_subquery_distinct_last_boolean() base.Where_subquery_distinct_last_boolean(); AssertSql( - ""); + @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOrBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +FROM [Gears] AS [g] +WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND (([g].[HasSoulPatch] <> CAST(1 AS bit)) AND (( + SELECT TOP(1) [t].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE ([g].[FullName] = [w].[OwnerFullName]) AND [w].[OwnerFullName] IS NOT NULL + ) AS [t] + ORDER BY [t].[Id] DESC) = CAST(1 AS bit))) +ORDER BY [g].[Nickname]"); } public override async Task Where_subquery_distinct_orderby_firstordefault_boolean(bool isAsync) @@ -1522,15 +1550,14 @@ public override async Task Where_subquery_distinct_orderby_firstordefault_boolea AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOrBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] -WHERE [g].[Discriminator] IN (N'Officer', N'Gear') AND (([g].[HasSoulPatch] = CAST(1 AS bit)) AND (COALESCE(( +WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND (([g].[HasSoulPatch] = CAST(1 AS bit)) AND (( SELECT TOP(1) [t].[IsAutomatic] FROM ( - SELECT DISTINCT [w].* + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] + WHERE ([g].[FullName] = [w].[OwnerFullName]) AND [w].[OwnerFullName] IS NOT NULL ) AS [t] - ORDER BY [t].[Id] -), CAST(0 AS bit)) = CAST(1 AS bit)))"); + ORDER BY [t].[Id]) = CAST(1 AS bit)))"); } public override async Task Where_subquery_distinct_orderby_firstordefault_boolean_with_pushdown(bool isAsync) @@ -1540,15 +1567,14 @@ public override async Task Where_subquery_distinct_orderby_firstordefault_boolea AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOrBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] -WHERE [g].[Discriminator] IN (N'Officer', N'Gear') AND (([g].[HasSoulPatch] = CAST(1 AS bit)) AND (( +WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND (([g].[HasSoulPatch] = CAST(1 AS bit)) AND (( SELECT TOP(1) [t].[IsAutomatic] FROM ( - SELECT DISTINCT [w].* + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] + WHERE ([g].[FullName] = [w].[OwnerFullName]) AND [w].[OwnerFullName] IS NOT NULL ) AS [t] - ORDER BY [t].[Id] -) = CAST(1 AS bit)))"); + ORDER BY [t].[Id]) = CAST(1 AS bit)))"); } public override async Task Where_subquery_union_firstordefault_boolean(bool isAsync) @@ -1641,7 +1667,16 @@ public override void Concat_with_scalar_projection() base.Concat_with_scalar_projection(); AssertSql( - ""); + @"SELECT [t].[Nickname] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOrBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] + FROM [Gears] AS [g] + WHERE [g].[Discriminator] IN (N'Gear', N'Officer') + UNION ALL + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOrBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] + FROM [Gears] AS [g0] + WHERE [g0].[Discriminator] IN (N'Gear', N'Officer') +) AS [t]"); } public override async Task Concat_with_groupings(bool isAsync) @@ -1730,7 +1765,18 @@ public override async Task Join_with_order_by_on_inner_sequence_navigation_trans await base.Join_with_order_by_on_inner_sequence_navigation_translated_to_subquery_composite_key(isAsync); AssertSql( - ""); + @"SELECT [g].[FullName], [t1].[Note] +FROM [Gears] AS [g] +INNER JOIN ( + SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[Note], [t0].[Nickname], [t0].[SquadId], [t0].[AssignedCityName], [t0].[CityOrBirthName], [t0].[Discriminator], [t0].[FullName], [t0].[HasSoulPatch], [t0].[LeaderNickname], [t0].[LeaderSquadId], [t0].[Rank] + FROM [Tags] AS [t] + LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOrBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] + FROM [Gears] AS [g0] + WHERE [g0].[Discriminator] IN (N'Gear', N'Officer') + ) AS [t0] ON (([t].[GearNickName] = [t0].[Nickname]) AND [t].[GearNickName] IS NOT NULL) AND (([t].[GearSquadId] = [t0].[SquadId]) AND [t].[GearSquadId] IS NOT NULL) +) AS [t1] ON [g].[FullName] = [t1].[FullName] +WHERE [g].[Discriminator] IN (N'Gear', N'Officer')"); } public override async Task Join_with_order_by_without_skip_or_take(bool isAsync) @@ -2133,7 +2179,17 @@ public override async Task Optional_navigation_type_compensation_works_with_pred await base.Optional_navigation_type_compensation_works_with_predicate_negated_complex1(isAsync); AssertSql( - ""); + @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOrBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] + FROM [Gears] AS [g] + WHERE [g].[Discriminator] IN (N'Gear', N'Officer') +) AS [t0] ON (([t].[GearNickName] = [t0].[Nickname]) AND [t].[GearNickName] IS NOT NULL) AND (([t].[GearSquadId] = [t0].[SquadId]) AND [t].[GearSquadId] IS NOT NULL) +WHERE CASE + WHEN [t0].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) + ELSE [t0].[HasSoulPatch] +END <> CAST(1 AS bit)"); } public override async Task Optional_navigation_type_compensation_works_with_predicate_negated_complex2(bool isAsync) @@ -2141,7 +2197,17 @@ public override async Task Optional_navigation_type_compensation_works_with_pred await base.Optional_navigation_type_compensation_works_with_predicate_negated_complex2(isAsync); AssertSql( - ""); + @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOrBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] + FROM [Gears] AS [g] + WHERE [g].[Discriminator] IN (N'Gear', N'Officer') +) AS [t0] ON (([t].[GearNickName] = [t0].[Nickname]) AND [t].[GearNickName] IS NOT NULL) AND (([t].[GearSquadId] = [t0].[SquadId]) AND [t].[GearSquadId] IS NOT NULL) +WHERE CASE + WHEN [t0].[HasSoulPatch] <> CAST(1 AS bit) THEN CAST(0 AS bit) + ELSE [t0].[HasSoulPatch] +END <> CAST(1 AS bit)"); } public override async Task Optional_navigation_type_compensation_works_with_conditional_expression(bool isAsync) @@ -3566,7 +3632,15 @@ public override void Comparing_entities_using_Equals_inheritance() base.Comparing_entities_using_Equals_inheritance(); AssertSql( - ""); + @"SELECT [g].[Nickname] AS [Nickname1], [t].[Nickname] AS [Nickname2] +FROM [Gears] AS [g] +CROSS JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOrBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] + FROM [Gears] AS [g0] + WHERE [g0].[Discriminator] IN (N'Gear', N'Officer') AND ([g0].[Discriminator] = N'Officer') +) AS [t] +WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND (([g].[Nickname] = [t].[Nickname]) AND ([g].[SquadId] = [t].[SquadId])) +ORDER BY [g].[Nickname]"); } public override void Contains_on_nullable_array_produces_correct_sql() @@ -4031,14 +4105,11 @@ public override async Task Correlated_collections_naked_navigation_with_ToList_f await base.Correlated_collections_naked_navigation_with_ToList_followed_by_projecting_count(isAsync); AssertSql( - @"SELECT ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] -) + @"SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] -WHERE [g].[Discriminator] IN (N'Officer', N'Gear') AND ([g].[Nickname] <> N'Marcus') -ORDER BY [g].[Nickname]"); +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND ([g].[Nickname] <> N'Marcus') +ORDER BY [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task Correlated_collections_naked_navigation_with_ToArray(bool isAsync) @@ -5245,14 +5316,6 @@ WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND ([g].[Discriminator] = N' ORDER BY [g].[Nickname], [g].[SquadId], [t1].[Id]"); } - public override async Task Include_collection_with_concat(bool isAsync) - { - await base.Include_collection_with_concat(isAsync); - - AssertSql( - ""); - } - public override async Task Negated_bool_ternary_inside_anonymous_type_in_projection(bool isAsync) { await base.Negated_bool_ternary_inside_anonymous_type_in_projection(isAsync); @@ -5729,20 +5792,17 @@ public override async Task Select_subquery_projecting_single_constant_null_of_no await base.Select_subquery_projecting_single_constant_null_of_non_mapped_type(isAsync); AssertSql( - @"SELECT [s].[Name], [s].[Id] -FROM [Squads] AS [s]", - // - @"@_outer_Id='1' - -SELECT TOP(1) 1 -FROM [Gears] AS [g] -WHERE ([g].[Discriminator] IN (N'Officer', N'Gear') AND (@_outer_Id = [g].[SquadId])) AND ([g].[HasSoulPatch] = CAST(1 AS bit))", - // - @"@_outer_Id='2' - -SELECT TOP(1) 1 -FROM [Gears] AS [g] -WHERE ([g].[Discriminator] IN (N'Officer', N'Gear') AND (@_outer_Id = [g].[SquadId])) AND ([g].[HasSoulPatch] = CAST(1 AS bit))"); + @"SELECT [s].[Name] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [t].[Nickname], [t].[SquadId] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] + FROM [Gears] AS [g] + WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND ([g].[HasSoulPatch] = CAST(1 AS bit)) + ) AS [t] + WHERE [t].[row] <= 1 +) AS [t0] ON [s].[Id] = [t0].[SquadId]"); } public override async Task Select_subquery_projecting_single_constant_of_non_mapped_type(bool isAsync) @@ -5750,20 +5810,17 @@ public override async Task Select_subquery_projecting_single_constant_of_non_map await base.Select_subquery_projecting_single_constant_of_non_mapped_type(isAsync); AssertSql( - @"SELECT [s].[Name], [s].[Id] -FROM [Squads] AS [s]", - // - @"@_outer_Id='1' - -SELECT TOP(1) 1 -FROM [Gears] AS [g] -WHERE ([g].[Discriminator] IN (N'Officer', N'Gear') AND (@_outer_Id = [g].[SquadId])) AND ([g].[HasSoulPatch] = CAST(1 AS bit))", - // - @"@_outer_Id='2' - -SELECT TOP(1) 1 -FROM [Gears] AS [g] -WHERE ([g].[Discriminator] IN (N'Officer', N'Gear') AND (@_outer_Id = [g].[SquadId])) AND ([g].[HasSoulPatch] = CAST(1 AS bit))"); + @"SELECT [s].[Name] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [t].[Nickname], [t].[SquadId] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] + FROM [Gears] AS [g] + WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND ([g].[HasSoulPatch] = CAST(1 AS bit)) + ) AS [t] + WHERE [t].[row] <= 1 +) AS [t0] ON [s].[Id] = [t0].[SquadId]"); } public override async Task Include_with_order_by_constant_null_of_non_mapped_type(bool isAsync) @@ -6344,7 +6401,7 @@ public override async Task GroupBy_Property_Include_Select_Average(bool isAsync) AssertSql( @"SELECT AVG(CAST([g].[SquadId] AS float)) FROM [Gears] AS [g] -WHERE [g].[Discriminator] IN (N'Officer', N'Gear') +WHERE [g].[Discriminator] IN (N'Gear', N'Officer') GROUP BY [g].[Rank]"); } @@ -6355,7 +6412,7 @@ public override async Task GroupBy_Property_Include_Select_Sum(bool isAsync) AssertSql( @"SELECT SUM([g].[SquadId]) FROM [Gears] AS [g] -WHERE [g].[Discriminator] IN (N'Officer', N'Gear') +WHERE [g].[Discriminator] IN (N'Gear', N'Officer') GROUP BY [g].[Rank]"); } @@ -6894,22 +6951,6 @@ WHERE [g0].[Discriminator] IN (N'Gear', N'Officer') WHERE [g].[Discriminator] IN (N'Gear', N'Officer')"); } - public override async Task CrossJoin_preserves_predicate_for_inner_source(bool isAsync) - { - await base.CrossJoin_preserves_predicate_for_inner_source(isAsync); - - AssertSql( - @"SELECT [g].[Nickname] AS [Nickname1], [t].[Nickname] AS [Nickname2] -FROM [Gears] AS [g] -CROSS JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOrBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] - FROM [Gears] AS [g0] - WHERE [g0].[Discriminator] IN (N'Gear', N'Officer') AND ([g0].[Discriminator] = N'Officer') -) AS [t] -WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND (([g].[Nickname] = [t].[Nickname]) AND ([g].[SquadId] = [t].[SquadId])) -ORDER BY [g].[Nickname]"); - } - public override async Task Project_collection_navigation_nested_with_take_composite_key(bool isAsync) { await base.Project_collection_navigation_nested_with_take_composite_key(isAsync); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/IncludeAsyncSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/IncludeAsyncSqlServerTest.cs index 8110f1f4449..caf59e572db 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/IncludeAsyncSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/IncludeAsyncSqlServerTest.cs @@ -55,13 +55,6 @@ FROM [Orders] AS [o] ORDER BY [c].[CustomerID], [t].[OrderID], [t].[OrderID0], [t].[ProductID]"); } - [SqlServerCondition(SqlServerCondition.SupportsOffset)] - // Test does not pass on SqlServer 2008. TODO: See issue#7160 - public override Task Include_duplicate_reference() - { - return base.Include_duplicate_reference(); - } - private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Functions.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Functions.cs index cd516be73a3..897f7e20b86 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Functions.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Functions.cs @@ -1326,7 +1326,10 @@ public override async Task Order_by_length_twice_followed_by_projection_of_naked await base.Order_by_length_twice_followed_by_projection_of_naked_collection_navigation(isAsync); AssertSql( - ""); + @"SELECT [c].[CustomerID], [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] +FROM [Customers] AS [c] +LEFT JOIN [Orders] AS [o] ON [c].[CustomerID] = [o].[CustomerID] +ORDER BY CAST(LEN([c].[CustomerID]) AS int), [c].[CustomerID], [o].[OrderID]"); } public override async Task Static_string_equals_in_predicate(bool isAsync) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.KeylessEntities.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.KeylessEntities.cs index e375c612ec2..8d2adb66a68 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.KeylessEntities.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.KeylessEntities.cs @@ -68,15 +68,11 @@ public override async Task KeylessEntity_with_mixed_tracking(bool isAsync) await base.KeylessEntity_with_mixed_tracking(isAsync); AssertSql( - @"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [t].[CustomerID] + @"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [o].[CustomerID] FROM [Customers] AS [c] -CROSS JOIN ( - SELECT [o].[CustomerID] - FROM ( - select * from ""Orders"" - ) AS [o] -) AS [t] -WHERE [t].[CustomerID] = [c].[CustomerID]"); +INNER JOIN ( + select * from ""Orders"" +) AS [o] ON [c].[CustomerID] = [o].[CustomerID]"); } public override async Task KeylessEntity_with_defining_query(bool isAsync) @@ -96,7 +92,14 @@ public override async Task KeylessEntity_with_defining_query_and_correlated_coll await base.KeylessEntity_with_defining_query_and_correlated_collection(isAsync); AssertSql( - ""); + @"SELECT [o].[OrderID], [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate] +FROM ( + select * from ""Orders"" +) AS [o] +LEFT JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID] +LEFT JOIN [Orders] AS [o0] ON [c].[CustomerID] = [o0].[CustomerID] +WHERE ([o].[CustomerID] = N'ALFKI') AND [o].[CustomerID] IS NOT NULL +ORDER BY [c].[CustomerID], [o].[OrderID], [o0].[OrderID]"); } public override async Task KeylessEntity_select_where_navigation(bool isAsync) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.cs index e872851a1bf..cfcd445f1de 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.cs @@ -896,25 +896,23 @@ public override async Task Where_subquery_anon_nested(bool isAsync) @"@__p_0='3' @__p_1='2' -SELECT [t0].[EmployeeID], [t0].[City], [t0].[Country], [t0].[FirstName], [t0].[ReportsTo], [t0].[Title], [t1].[OrderID], [t1].[CustomerID], [t1].[EmployeeID], [t1].[OrderDate], [t2].[CustomerID], [t2].[Address], [t2].[City], [t2].[CompanyName], [t2].[ContactName], [t2].[ContactTitle], [t2].[Country], [t2].[Fax], [t2].[Phone], [t2].[PostalCode], [t2].[Region] +SELECT [t].[EmployeeID], [t].[City], [t].[Country], [t].[FirstName], [t].[ReportsTo], [t].[Title], [t0].[OrderID], [t0].[CustomerID], [t0].[EmployeeID], [t0].[OrderDate], [t1].[CustomerID], [t1].[Address], [t1].[City], [t1].[CompanyName], [t1].[ContactName], [t1].[ContactTitle], [t1].[Country], [t1].[Fax], [t1].[Phone], [t1].[PostalCode], [t1].[Region] FROM ( - SELECT [t].[EmployeeID], [t].[City], [t].[Country], [t].[FirstName], [t].[ReportsTo], [t].[Title] - FROM ( - SELECT TOP(@__p_0) [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] - FROM [Employees] AS [e] - ORDER BY [e].[EmployeeID] - ) AS [t] - WHERE ([t].[City] = N'Seattle') AND [t].[City] IS NOT NULL -) AS [t0] + SELECT TOP(@__p_0) [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] + FROM [Employees] AS [e] + ORDER BY [e].[EmployeeID] +) AS [t] CROSS JOIN ( SELECT TOP(5) [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] ORDER BY [o].[OrderID] -) AS [t1] +) AS [t0] CROSS JOIN ( SELECT TOP(@__p_1) [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] -) AS [t2]"); +) AS [t1] +WHERE ([t].[City] = N'Seattle') AND [t].[City] IS NOT NULL +ORDER BY [t].[EmployeeID]"); } public override async Task OrderBy_SelectMany(bool isAsync) @@ -1081,7 +1079,14 @@ public override async Task Join_Customers_Orders_Skip_Take_followed_by_constant_ await base.Join_Customers_Orders_Skip_Take_followed_by_constant_projection(isAsync); AssertSql( - ""); + @"@__p_0='10' +@__p_1='5' + +SELECT N'Foo' +FROM [Customers] AS [c] +INNER JOIN [Orders] AS [o] ON [c].[CustomerID] = [o].[CustomerID] +ORDER BY [o].[OrderID] +OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY"); } [SqlServerCondition(SqlServerCondition.SupportsOffset)] @@ -1745,7 +1750,7 @@ FROM [Customers] AS [c] WHERE ([c].[CustomerID] = N'ALFKI') AND EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE ([c].[CustomerID] = [o].[CustomerID]) AND ([o].[OrderDate] = '2008-10-24T00:00:00.000'))"); + WHERE (([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL) AND (([o].[OrderDate] = '2008-10-24T00:00:00.000') AND [o].[OrderDate] IS NOT NULL))"); } public override async Task Where_Join_Exists(bool isAsync) @@ -2247,7 +2252,8 @@ public override async Task OrderBy_multiple(bool isAsync) AssertSql( @"SELECT [c].[City] FROM [Customers] AS [c] -ORDER BY [c].[Country], [c].[CustomerID]"); +WHERE [c].[CustomerID] LIKE N'A%' +ORDER BY [c].[Country], [c].[City]"); } public override async Task OrderBy_ThenBy_Any(bool isAsync) @@ -4376,10 +4382,10 @@ public override async Task Compare_two_collection_navigations_using_equals(bool await base.Compare_two_collection_navigations_using_equals(isAsync); AssertSql( - @"SELECT [c1].[CustomerID] AS [Id1], [c2].[CustomerID] AS [Id2] -FROM [Customers] AS [c1] -CROSS JOIN [Customers] AS [c2] -WHERE (([c1].[CustomerID] = N'ALFKI') AND ([c2].[CustomerID] = N'ALFKI')) AND ([c1].[CustomerID] = [c2].[CustomerID])"); + @"SELECT [c].[CustomerID] AS [Id1], [c0].[CustomerID] AS [Id2] +FROM [Customers] AS [c] +CROSS JOIN [Customers] AS [c0] +WHERE (([c].[CustomerID] = N'ALFKI') AND ([c0].[CustomerID] = N'ALFKI')) AND ([c].[CustomerID] = [c0].[CustomerID])"); } public override async Task Compare_two_collection_navigations_with_different_property_chains(bool isAsync) @@ -4423,21 +4429,18 @@ public override async Task Complex_nested_query_doesnt_try_binding_to_grandparen await base.Complex_nested_query_doesnt_try_binding_to_grandparent_when_parent_returns_complex_result(isAsync); AssertSql( - @"SELECT [c].[CustomerID] + @"SELECT [c].[CustomerID], [t].[c], [t].[CustomerID], [t].[OrderID] FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'ALFKI'", - // - @"@_outer_CustomerID1='ALFKI' (Size = 5) -@_outer_CustomerID2='ALFKI' (Size = 4000) -@_outer_CustomerID='ALFKI' (Size = 5) - -SELECT ( - SELECT COUNT(*) +OUTER APPLY ( + SELECT ( + SELECT COUNT(*) + FROM [Orders] AS [o] + WHERE ([c].[CustomerID] = [o].[CustomerID]) AND [o].[CustomerID] IS NOT NULL) AS [c], [c].[CustomerID], [o0].[OrderID] FROM [Orders] AS [o0] - WHERE @_outer_CustomerID1 = [o0].[CustomerID] -) AS [InnerOrder], @_outer_CustomerID2 AS [Id] -FROM [Orders] AS [o] -WHERE @_outer_CustomerID = [o].[CustomerID]"); + WHERE ([c].[CustomerID] = [o0].[CustomerID]) AND [o0].[CustomerID] IS NOT NULL +) AS [t] +WHERE [c].[CustomerID] = N'ALFKI' +ORDER BY [c].[CustomerID], [t].[OrderID]"); } public override async Task Complex_nested_query_properly_binds_to_grandparent_when_parent_returns_scalar_result(bool isAsync) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteTest.cs index a58f8dae5e2..6ca501713cc 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteTest.cs @@ -24,5 +24,11 @@ public override Task Project_collection_navigation_nested_with_take(bool isAsync { return base.Project_collection_navigation_nested_with_take(isAsync); } + + [ConditionalFact(Skip = "Issue #17230")] + public override void Include_inside_subquery() + { + base.Include_inside_subquery(); + } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/SimpleQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/SimpleQuerySqliteTest.cs index 87ec7b298f2..c20c0321d94 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/SimpleQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/SimpleQuerySqliteTest.cs @@ -1318,6 +1318,10 @@ public override void Select_nested_collection_multi_level() public override Task SelectMany_correlated_with_outer_4(bool isAsync) => null; + public override Task Complex_nested_query_doesnt_try_binding_to_grandparent_when_parent_returns_complex_result(bool isAsync) => null; + + public override Task SelectMany_correlated_subquery_hard(bool isAsync) => null; + [ConditionalTheory(Skip = "Issue#17324")] public override Task Project_single_element_from_collection_with_OrderBy_over_navigation_Take_and_FirstOrDefault_2(bool isAsync) {