From 2f3701af478b6cd4df817fb27b6227f323c41518 Mon Sep 17 00:00:00 2001 From: Smit Patel Date: Fri, 10 Apr 2020 18:34:52 -0700 Subject: [PATCH] Query: Add identifier appropriately when generating joins We skipped doing it during left join which was incorrect. We need to apply it for every join and account for it could be null for LeftJoin/OuterApply. - Make columnExpression.Type nullble if it is nullable. - Add some fancy code in TestSqlLoggerFactory to write directly into file updating baselines (I ran into updating 234 baselines). - Off by default - Can set indent if it is higher than usual - Only works when number of lines do not change --- ....CustomShaperCompilingExpressionVisitor.cs | 4 +- .../Query/SqlExpressions/ColumnExpression.cs | 2 +- .../Query/SqlExpressions/SelectExpression.cs | 19 ++- .../TestUtilities/TestSqlLoggerFactory.cs | 76 ++++++--- .../Query/NorthwindIncludeQueryTestBase.cs | 156 +++++++++++++++++- .../ComplexNavigationsQuerySqlServerTest.cs | 118 ++++++------- .../Query/GearsOfWarQuerySqlServerTest.cs | 144 ++++++++-------- ...eritanceRelationshipsQuerySqlServerTest.cs | 8 +- .../NorthwindIncludeQuerySqlServerTest.cs | 84 +++++++++- ...thwindKeylessEntitiesQuerySqlServerTest.cs | 2 +- .../NorthwindNavigationsQuerySqlServerTest.cs | 10 +- ...NorthwindQueryFiltersQuerySqlServerTest.cs | 10 +- .../NorthwindSelectQuerySqlServerTest.cs | 6 +- .../Query/OwnedQuerySqlServerTest.cs | 22 +-- .../Query/QueryBugsTest.cs | 14 +- .../Query/NorthwindIncludeQuerySqliteTest.cs | 9 + 16 files changed, 472 insertions(+), 212 deletions(-) diff --git a/src/EFCore.Relational/Query/RelationalShapedQueryCompilingExpressionVisitor.CustomShaperCompilingExpressionVisitor.cs b/src/EFCore.Relational/Query/RelationalShapedQueryCompilingExpressionVisitor.CustomShaperCompilingExpressionVisitor.cs index 495f976f799..9d10f020386 100644 --- a/src/EFCore.Relational/Query/RelationalShapedQueryCompilingExpressionVisitor.CustomShaperCompilingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/RelationalShapedQueryCompilingExpressionVisitor.CustomShaperCompilingExpressionVisitor.cs @@ -125,7 +125,7 @@ private static void PopulateCollection( } var innerKey = selfIdentifier(queryContext, dbDataReader); - if (innerKey.Any(e => e == null)) + if (innerKey.Length > 0 && innerKey.All(e => e == null)) { // No correlated element return; @@ -236,7 +236,7 @@ private static void PopulateIncludeCollection } var innerKey = selfIdentifier(queryContext, dbDataReader); - if (innerKey.Any(e => e == null)) + if (innerKey.All(e => e == null)) { // No correlated element return; diff --git a/src/EFCore.Relational/Query/SqlExpressions/ColumnExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/ColumnExpression.cs index 7373d3d9ee9..961c60d8436 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/ColumnExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/ColumnExpression.cs @@ -38,7 +38,7 @@ private static bool IsNullableProjection(ProjectionExpression projectionExpressi }; private ColumnExpression(string name, TableExpressionBase table, Type type, RelationalTypeMapping typeMapping, bool nullable) - : base(type, typeMapping) + : base(nullable ? type.MakeNullable() : type, typeMapping) { Check.NotEmpty(name, nameof(name)); Check.NotNull(table, nameof(table)); diff --git a/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs index 2db70828552..5d039d7ff06 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs @@ -24,10 +24,10 @@ private readonly IDictionary _tables = new List(); private readonly List _groupBy = new List(); private readonly List _orderings = new List(); - private readonly List<(SqlExpression Column, ValueComparer Comparer)> _identifier - = new List<(SqlExpression Column, ValueComparer Comparer)>(); - private readonly List<(SqlExpression Column, ValueComparer Comparer)> _childIdentifiers - = new List<(SqlExpression Column, ValueComparer Comparer)>(); + private readonly List<(ColumnExpression Column, ValueComparer Comparer)> _identifier + = new List<(ColumnExpression Column, ValueComparer Comparer)>(); + private readonly List<(ColumnExpression Column, ValueComparer Comparer)> _childIdentifiers + = new List<(ColumnExpression Column, ValueComparer Comparer)>(); private readonly List _pendingCollections = new List(); private IDictionary _projectionMapping = new Dictionary(); @@ -979,7 +979,7 @@ public Expression ApplyCollectionJoin( foreach (var identifier in innerSelectExpression._identifier.Concat(innerSelectExpression._childIdentifiers)) { - var updatedColumn = MakeNullable(identifier.Column); + var updatedColumn = identifier.Column.MakeNullable(); _childIdentifiers.Add((updatedColumn, identifier.Comparer)); AppendOrdering(new OrderingExpression(updatedColumn, ascending: true)); } @@ -1000,7 +1000,7 @@ private static SqlExpression MakeNullable(SqlExpression sqlExpression) => sqlExpression is ColumnExpression column ? column.MakeNullable() : sqlExpression; private (Expression, IReadOnlyList) GetIdentifierAccessor( - IEnumerable<(SqlExpression Column, ValueComparer Comparer)> identifyingProjection) + IEnumerable<(ColumnExpression Column, ValueComparer Comparer)> identifyingProjection) { var updatedExpressions = new List(); var comparers = new List(); @@ -1383,7 +1383,12 @@ private void AddJoin( .Remap(joinPredicate); } - if (joinType != JoinType.LeftJoin) + if (joinType == JoinType.LeftJoin + || joinType == JoinType.OuterApply) + { + _identifier.AddRange(innerSelectExpression._identifier.Select(e => (e.Column.MakeNullable(), e.Comparer))); + } + else { _identifier.AddRange(innerSelectExpression._identifier); } diff --git a/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs b/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs index afab379cd8f..77ba4f4c0d7 100644 --- a/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs +++ b/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs @@ -51,40 +51,76 @@ public void AssertBaseline(string[] expected) } catch { + var writeToLog = true; var methodCallLine = Environment.StackTrace.Split( new[] { _eol }, StringSplitOptions.RemoveEmptyEntries)[3].Substring(6); - var testName = methodCallLine.Substring(0, methodCallLine.IndexOf(')') + 1); - var lineIndex = methodCallLine.LastIndexOf("line", StringComparison.Ordinal); - var lineNumber = lineIndex > 0 ? methodCallLine.Substring(lineIndex) : ""; + var indexMethodEnding = methodCallLine.IndexOf(')') + 1; + var testName = methodCallLine.Substring(0, indexMethodEnding); + var parts = methodCallLine[indexMethodEnding..].Split(" ", StringSplitOptions.RemoveEmptyEntries); + var fileName = parts[1][..^5]; + var lineNumber = int.Parse(parts[2]); - const string indent = FileNewLine + " "; - - var currentDirectory = Directory.GetCurrentDirectory(); - var logFile = currentDirectory.Substring( - 0, - currentDirectory.LastIndexOf("\\artifacts\\", StringComparison.Ordinal) + 1) - + "QueryBaseline.txt"; + if (writeToLog || SqlStatements.Count > 9) + { + var currentDirectory = Directory.GetCurrentDirectory(); + var logFile = currentDirectory.Substring( + 0, + currentDirectory.LastIndexOf("\\artifacts\\", StringComparison.Ordinal) + 1) + + "QueryBaseline.txt"; - var testInfo = testName + " : " + lineNumber + FileNewLine; + var testInfo = testName + " : " + lineNumber + FileNewLine; + const string indent = FileNewLine + " "; - var newBaseLine = $@" AssertSql( + var newBaseLine = $@" AssertSql( {string.Join("," + indent + "//" + indent, SqlStatements.Take(9).Select(sql => "@\"" + sql.Replace("\"", "\"\"") + "\""))}); "; - if (SqlStatements.Count > 9) - { - newBaseLine += "Output truncated."; - } + if (SqlStatements.Count > 9) + { + newBaseLine += "Output truncated."; + } - Logger.TestOutputHelper?.WriteLine("---- New Baseline -------------------------------------------------------------------"); - Logger.TestOutputHelper?.WriteLine(newBaseLine); + Logger.TestOutputHelper?.WriteLine("---- New Baseline -------------------------------------------------------------------"); + Logger.TestOutputHelper?.WriteLine(newBaseLine); - var contents = testInfo + newBaseLine + FileNewLine + FileNewLine; + var contents = testInfo + newBaseLine + FileNewLine + FileNewLine; - File.AppendAllText(logFile, contents); + File.AppendAllText(logFile, contents); + } + else + { + var indentCount = 3; + var initialIndent = string.Join("", Enumerable.Repeat(" ", indentCount)); + var additionalIndent = initialIndent + " "; + var existingLines = File.ReadAllLines(fileName); + var newBaseLine = $@"{initialIndent}AssertSql( +{additionalIndent}{string.Join("," + FileNewLine + additionalIndent + "//" + FileNewLine + additionalIndent, SqlStatements.Take(9).Select(sql => "@\"" + sql.Replace("\"", "\"\"") + "\""))});"; + var newLines = newBaseLine.Split(Environment.NewLine); + using (var fileStream = File.Open(fileName, FileMode.Open)) + { + using (var streamWriter = new StreamWriter(fileStream)) + { + for (var i = 1; i <= existingLines.Length; i++) + { + if (i == lineNumber) + { + for (var j = 0; j < newLines.Length; i++, j++) + { + streamWriter.WriteLine(newLines[j]); + } + } + + streamWriter.WriteLine(existingLines[i - 1]); + } + } + } + + Logger.TestOutputHelper?.WriteLine("---- New Baseline -------------------------------------------------------------------"); + Logger.TestOutputHelper?.WriteLine(newBaseLine); + } throw; } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindIncludeQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindIncludeQueryTestBase.cs index c5d1991eb6b..fabb241ccfa 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindIncludeQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindIncludeQueryTestBase.cs @@ -827,26 +827,170 @@ var orders [ConditionalTheory] [InlineData(false)] [InlineData(true)] - public virtual void Include_collection_on_join_clause_with_filter(bool useString) + public virtual void Include_collection_with_join_clause_with_filter(bool useString) { using var context = CreateContext(); var customers = useString ? (from c in context.Set().Include("Orders") join o in context.Set() on c.CustomerID equals o.CustomerID - where c.CustomerID == "ALFKI" + where c.CustomerID.StartsWith("F") select c) .ToList() : (from c in context.Set().Include(c => c.Orders) join o in context.Set() on c.CustomerID equals o.CustomerID - where c.CustomerID == "ALFKI" + where c.CustomerID.StartsWith("F") select c) .ToList(); - Assert.Equal(6, customers.Count); - Assert.Equal(36, customers.SelectMany(c => c.Orders).Count()); + Assert.Equal(63, customers.Count); + Assert.Equal(769, customers.SelectMany(c => c.Orders).Count()); Assert.True(customers.SelectMany(c => c.Orders).All(o => o.Customer != null)); - Assert.Equal(1 + 6, context.ChangeTracker.Entries().Count()); + Assert.Equal(7 + 63, context.ChangeTracker.Entries().Count()); + + foreach (var customer in customers) + { + CheckIsLoaded( + context, + customer, + ordersLoaded: true, + orderDetailsLoaded: false, + productLoaded: false); + } + } + + [ConditionalTheory] + [InlineData(false)] + [InlineData(true)] + public virtual void Include_collection_with_left_join_clause_with_filter(bool useString) + { + using var context = CreateContext(); + var customers + = useString + ? (from c in context.Set().Include("Orders") + join o in context.Set() on c.CustomerID equals o.CustomerID into grouping + from o in grouping.DefaultIfEmpty() + where c.CustomerID.StartsWith("F") + select c) + .ToList() + : (from c in context.Set().Include(c => c.Orders) + join o in context.Set() on c.CustomerID equals o.CustomerID into grouping + from o in grouping.DefaultIfEmpty() + where c.CustomerID.StartsWith("F") + select c) + .ToList(); + + Assert.Equal(64, customers.Count); + Assert.Equal(769, customers.SelectMany(c => c.Orders).Count()); + Assert.True(customers.SelectMany(c => c.Orders).All(o => o.Customer != null)); + Assert.Equal(8 + 63, context.ChangeTracker.Entries().Count()); + + foreach (var customer in customers) + { + CheckIsLoaded( + context, + customer, + ordersLoaded: true, + orderDetailsLoaded: false, + productLoaded: false); + } + } + + [ConditionalTheory] + [InlineData(false)] + [InlineData(true)] + public virtual void Include_collection_with_cross_join_clause_with_filter(bool useString) + { + using var context = CreateContext(); + var customers + = useString + ? (from c in context.Set().Include("Orders") + from o in context.Set().OrderBy(o => o.OrderID).Take(5) + where c.CustomerID.StartsWith("F") + select c) + .ToList() + : (from c in context.Set().Include(c => c.Orders) + from o in context.Set().OrderBy(o => o.OrderID).Take(5) + where c.CustomerID.StartsWith("F") + select c) + .ToList(); + + Assert.Equal(40, customers.Count); + Assert.Equal(315, customers.SelectMany(c => c.Orders).Count()); + Assert.True(customers.SelectMany(c => c.Orders).All(o => o.Customer != null)); + Assert.Equal(8 + 63, context.ChangeTracker.Entries().Count()); + + foreach (var customer in customers) + { + CheckIsLoaded( + context, + customer, + ordersLoaded: true, + orderDetailsLoaded: false, + productLoaded: false); + } + } + + [ConditionalTheory] + [InlineData(false)] + [InlineData(true)] + public virtual void Include_collection_with_cross_apply_with_filter(bool useString) + { + using var context = CreateContext(); + var customers + = useString + ? (from c in context.Set().Include("Orders") + from o in context.Set().Where(o => o.CustomerID == c.CustomerID).OrderBy(o => c.CustomerID).Take(5) + where c.CustomerID.StartsWith("F") + select c) + .ToList() + : (from c in context.Set().Include(c => c.Orders) + from o in context.Set().Where(o => o.CustomerID == c.CustomerID).OrderBy(o => c.CustomerID).Take(5) + where c.CustomerID.StartsWith("F") + select c) + .ToList(); + + Assert.Equal(33, customers.Count); + Assert.Equal(309, customers.SelectMany(c => c.Orders).Count()); + Assert.True(customers.SelectMany(c => c.Orders).All(o => o.Customer != null)); + Assert.Equal(7 + 63, context.ChangeTracker.Entries().Count()); + + foreach (var customer in customers) + { + CheckIsLoaded( + context, + customer, + ordersLoaded: true, + orderDetailsLoaded: false, + productLoaded: false); + } + } + + [ConditionalTheory] + [InlineData(false)] + [InlineData(true)] + public virtual void Include_collection_with_outer_apply_with_filter(bool useString) + { + using var context = CreateContext(); + var customers + = useString + ? (from c in context.Set().Include("Orders") + from o in context.Set().Where(o => o.CustomerID == c.CustomerID) + .OrderBy(o => c.CustomerID).Take(5).DefaultIfEmpty() + where c.CustomerID.StartsWith("F") + select c) + .ToList() + : (from c in context.Set().Include(c => c.Orders) + from o in context.Set().Where(o => o.CustomerID == c.CustomerID) + .OrderBy(o => c.CustomerID).Take(5).DefaultIfEmpty() + where c.CustomerID.StartsWith("F") + select c) + .ToList(); + + Assert.Equal(34, customers.Count); + Assert.Equal(309, customers.SelectMany(c => c.Orders).Count()); + Assert.True(customers.SelectMany(c => c.Orders).All(o => o.Customer != null)); + Assert.Equal(8 + 63, context.ChangeTracker.Entries().Count()); foreach (var customer in customers) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs index 7d28b7a9532..1a6bf84ec46 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Linq; @@ -208,7 +208,7 @@ LEFT JOIN ( FROM [Globalizations] AS [g0] LEFT JOIN [Languages] AS [l0] ON [g0].[LanguageName] = [l0].[Name] ) AS [t0] ON [m0].[DefaultText] = [t0].[ComplexNavigationStringDefaultText] -ORDER BY [f].[Name], [t].[Text], [t0].[Text]"); +ORDER BY [f].[Name], [m].[DefaultText], [m0].[DefaultText], [t].[Text], [t].[Name], [t0].[Text], [t0].[Name]"); } public override async Task Join_navigation_key_access_optional(bool async) @@ -548,7 +548,7 @@ LEFT JOIN ( FROM [LevelTwo] AS [l2] LEFT JOIN [LevelThree] AS [l3] ON [l2].[Id] = [l3].[Level2_Optional_Id] ) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [l1].[Id], [t].[Id]"); +ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [t].[Id], [t].[Id0]"); } public override async Task Multiple_complex_includes_self_ref(bool async) @@ -565,7 +565,7 @@ LEFT JOIN ( FROM [LevelOne] AS [l2] LEFT JOIN [LevelOne] AS [l3] ON [l2].[OneToOne_Optional_Self1Id] = [l3].[Id] ) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Self_Inverse1Id] -ORDER BY [l].[Id], [l1].[Id], [t].[Id]"); +ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [t].[Id], [t].[Id0]"); } public override async Task Multiple_complex_include_select(bool async) @@ -582,7 +582,7 @@ LEFT JOIN ( FROM [LevelTwo] AS [l2] LEFT JOIN [LevelThree] AS [l3] ON [l2].[Id] = [l3].[Level2_Optional_Id] ) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [l1].[Id], [t].[Id]"); +ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [t].[Id], [t].[Id0]"); } public override async Task Select_nav_prop_reference_optional1(bool async) @@ -1067,7 +1067,7 @@ FROM [LevelThree] AS [l1] LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Required_Id] ) AS [t] ON [l0].[Id] = [t].[OneToMany_Required_Inverse3Id] WHERE ([l0].[Name] <> N'L2 09') OR [l0].[Name] IS NULL -ORDER BY [l].[Id], [t].[Id]"); +ORDER BY [l].[Id], [l0].[Id], [t].[Id], [t].[Id0]"); } public override async Task Join_flattening_bug_4539(bool async) @@ -1211,7 +1211,7 @@ LEFT JOIN ( FROM [LevelTwo] AS [l2] LEFT JOIN [LevelThree] AS [l3] ON [l2].[Id] = [l3].[Level2_Optional_Id] ) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [l1].[Id], [t].[Id]"); +ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [t].[Id], [t].[Id0]"); } public override async Task Where_navigation_property_to_collection(bool async) @@ -1274,7 +1274,7 @@ OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY LEFT JOIN [LevelTwo] AS [l0] ON [t].[Id] = [l0].[Level1_Required_Id] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] LEFT JOIN [LevelThree] AS [l2] ON [l0].[Id] = [l2].[OneToMany_Required_Inverse3Id] -ORDER BY [t].[Name], [t].[Id], [l1].[Id], [l2].[Id]"); +ORDER BY [t].[Name], [t].[Id], [l0].[Id], [l1].[Id], [l2].[Id]"); } public override async Task Complex_multi_include_with_order_by_and_paging_joins_on_correct_key(bool async) @@ -1296,7 +1296,7 @@ OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY LEFT JOIN [LevelTwo] AS [l1] ON [t].[Id] = [l1].[Level1_Required_Id] LEFT JOIN [LevelThree] AS [l2] ON [l0].[Id] = [l2].[OneToMany_Optional_Inverse3Id] LEFT JOIN [LevelThree] AS [l3] ON [l1].[Id] = [l3].[OneToMany_Required_Inverse3Id] -ORDER BY [t].[Name], [t].[Id], [l2].[Id], [l3].[Id]"); +ORDER BY [t].[Name], [t].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [l3].[Id]"); } public override async Task Complex_multi_include_with_order_by_and_paging_joins_on_correct_key2(bool async) @@ -1317,7 +1317,7 @@ OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY LEFT JOIN [LevelTwo] AS [l0] ON [t].[Id] = [l0].[Level1_Optional_Id] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Required_Id] LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[OneToMany_Optional_Inverse4Id] -ORDER BY [t].[Name], [t].[Id], [l2].[Id]"); +ORDER BY [t].[Name], [t].[Id], [l0].[Id], [l1].[Id], [l2].[Id]"); } public override async Task Multiple_include_with_multiple_optional_navigations(bool async) @@ -1325,7 +1325,7 @@ public override async Task Multiple_include_with_multiple_optional_navigations(b await base.Multiple_include_with_multiple_optional_navigations(async); AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id], [l3].[Id], [l3].[Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Name], [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Optional_Self_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToMany_Required_Self_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id], [l3].[OneToOne_Optional_Self2Id], [l4].[Id], [l4].[Level2_Optional_Id], [l4].[Level2_Required_Id], [l4].[Name], [l4].[OneToMany_Optional_Inverse3Id], [l4].[OneToMany_Optional_Self_Inverse3Id], [l4].[OneToMany_Required_Inverse3Id], [l4].[OneToMany_Required_Self_Inverse3Id], [l4].[OneToOne_Optional_PK_Inverse3Id], [l4].[OneToOne_Optional_Self3Id], [l5].[Id], [l5].[Level2_Optional_Id], [l5].[Level2_Required_Id], [l5].[Name], [l5].[OneToMany_Optional_Inverse3Id], [l5].[OneToMany_Optional_Self_Inverse3Id], [l5].[OneToMany_Required_Inverse3Id], [l5].[OneToMany_Required_Self_Inverse3Id], [l5].[OneToOne_Optional_PK_Inverse3Id], [l5].[OneToOne_Optional_Self3Id] + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id], [l3].[Id], [l3].[Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Name], [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Optional_Self_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToMany_Required_Self_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id], [l3].[OneToOne_Optional_Self2Id], [l4].[Id], [l4].[Level2_Optional_Id], [l4].[Level2_Required_Id], [l4].[Name], [l4].[OneToMany_Optional_Inverse3Id], [l4].[OneToMany_Optional_Self_Inverse3Id], [l4].[OneToMany_Required_Inverse3Id], [l4].[OneToMany_Required_Self_Inverse3Id], [l4].[OneToOne_Optional_PK_Inverse3Id], [l4].[OneToOne_Optional_Self3Id], [l1].[Id], [l5].[Id], [l5].[Level2_Optional_Id], [l5].[Level2_Required_Id], [l5].[Name], [l5].[OneToMany_Optional_Inverse3Id], [l5].[OneToMany_Optional_Self_Inverse3Id], [l5].[OneToMany_Required_Inverse3Id], [l5].[OneToMany_Required_Self_Inverse3Id], [l5].[OneToOne_Optional_PK_Inverse3Id], [l5].[OneToOne_Optional_Self3Id] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] @@ -1334,7 +1334,7 @@ FROM [LevelOne] AS [l] LEFT JOIN [LevelThree] AS [l4] ON [l3].[Id] = [l4].[Level2_Optional_Id] LEFT JOIN [LevelThree] AS [l5] ON [l0].[Id] = [l5].[OneToMany_Optional_Inverse3Id] WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL -ORDER BY [l].[Id], [l5].[Id]"); +ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [l3].[Id], [l4].[Id], [l5].[Id]"); } public override async Task Correlated_subquery_doesnt_project_unnecessary_columns_in_top_level(bool async) @@ -1611,7 +1611,7 @@ FROM [LevelOne] AS [l] INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Required_Id] LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[OneToMany_Optional_Inverse4Id] -ORDER BY [l].[Id], [l0].[Id], [l2].[Id]"); +ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id]"); } public override async Task Multiple_SelectMany_with_Include(bool async) @@ -1625,7 +1625,7 @@ FROM [LevelOne] AS [l] INNER JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Required_Id] LEFT JOIN [LevelFour] AS [l3] ON [l1].[Id] = [l3].[OneToMany_Optional_Inverse4Id] -ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l3].[Id]"); +ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [l3].[Id]"); } public override async Task SelectMany_with_string_based_Include1(bool async) @@ -2087,7 +2087,7 @@ await base.Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpt async); AssertSql( - @"SELECT [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l14].[Name], [l].[Id], [t].[Id], [t].[Id0], [t1].[Id], [t1].[Date], [t1].[Level1_Optional_Id], [t1].[Level1_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse2Id], [t1].[OneToMany_Optional_Self_Inverse2Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[OneToMany_Required_Self_Inverse2Id], [t1].[OneToOne_Optional_PK_Inverse2Id], [t1].[OneToOne_Optional_Self2Id] + @"SELECT [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l14].[Name], [l].[Id], [l0].[Id], [l1].[Id], [t].[Id], [t].[Id0], [t].[Id1], [t].[Id2], [t0].[Id], [t0].[Id0], [t0].[Id1], [t0].[Id2], [l11].[Id], [l12].[Id], [l13].[Id], [l14].[Id], [t1].[Id], [t1].[Date], [t1].[Level1_Optional_Id], [t1].[Level1_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse2Id], [t1].[OneToMany_Optional_Self_Inverse2Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[OneToMany_Required_Self_Inverse2Id], [t1].[OneToOne_Optional_PK_Inverse2Id], [t1].[OneToOne_Optional_Self2Id] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Optional_Id] @@ -2116,7 +2116,7 @@ FROM [LevelTwo] AS [l15] WHERE [l15].[Id] <> 42 ) AS [t1] ON [t].[Id2] = [t1].[OneToMany_Optional_Self_Inverse2Id] WHERE ([l11].[Name] <> N'Foo') OR [l11].[Name] IS NULL -ORDER BY [l12].[Id], [l].[Id], [t].[Id], [t].[Id0], [t1].[Id]"); +ORDER BY [l12].[Id], [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [t].[Id], [t].[Id0], [t].[Id1], [t].[Id2], [t0].[Id], [t0].[Id0], [t0].[Id1], [t0].[Id2], [l11].[Id], [l13].[Id], [l14].[Id], [t1].[Id]"); } public override async Task Multiple_SelectMany_with_navigation_and_explicit_DefaultIfEmpty(bool async) @@ -2978,11 +2978,11 @@ public override async Task Project_collection_navigation_nested(bool async) await base.Project_collection_navigation_nested(async); AssertSql( - @"SELECT [l].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] + @"SELECT [l].[Id], [l0].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l1].[Id]"); +ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); } public override async Task Project_collection_navigation_using_ef_property(bool async) @@ -2990,11 +2990,11 @@ public override async Task Project_collection_navigation_using_ef_property(bool await base.Project_collection_navigation_using_ef_property(async); AssertSql( - @"SELECT [l].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] + @"SELECT [l].[Id], [l0].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l1].[Id]"); +ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); } public override async Task Project_collection_navigation_nested_anonymous(bool async) @@ -3002,11 +3002,11 @@ public override async Task Project_collection_navigation_nested_anonymous(bool a await base.Project_collection_navigation_nested_anonymous(async); AssertSql( - @"SELECT [l].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] + @"SELECT [l].[Id], [l0].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l1].[Id]"); +ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); } public override async Task Project_collection_navigation_count(bool async) @@ -3070,7 +3070,7 @@ public override async Task Project_navigation_and_collection(bool async) FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l1].[Id]"); +ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); } public override async Task Include_inside_subquery(bool async) @@ -3198,7 +3198,7 @@ FROM [InheritanceOne] AS [i] LEFT JOIN [InheritanceLeafOne] AS [i0] ON [i].[Id] = [i0].[DifferentTypeReference_InheritanceDerived1Id] LEFT JOIN [InheritanceLeafTwo] AS [i1] ON [i].[Id] = [i1].[DifferentTypeReference_InheritanceDerived2Id] LEFT JOIN [InheritanceTwo] AS [i2] ON [i1].[Id] = [i2].[InheritanceLeaf2Id] -ORDER BY [i].[Id], [i2].[Id]"); +ORDER BY [i].[Id], [i0].[Id], [i1].[Id], [i2].[Id]"); } public override async Task String_include_multiple_derived_collection_navigation_with_same_name_and_same_type(bool async) @@ -3261,7 +3261,7 @@ FROM [InheritanceOne] AS [i3] LEFT JOIN [InheritanceLeafOne] AS [i4] ON [i3].[Id] = [i4].[SameTypeReference_InheritanceDerived1Id] LEFT JOIN [InheritanceLeafOne] AS [i5] ON [i3].[Id] = [i5].[SameTypeReference_InheritanceDerived2Id] ) AS [t] ON [i].[Id] = [t].[InheritanceBase2Id1] -ORDER BY [i].[Id], [i1].[Id], [i2].[Id], [t].[Id]"); +ORDER BY [i].[Id], [i0].[Id], [i1].[Id], [i2].[Id], [t].[Id], [t].[Id0], [t].[Id1]"); } public override async Task Include_reference_collection_order_by_reference_navigation(bool async) @@ -3398,17 +3398,17 @@ public override async Task Null_check_in_anonymous_type_projection_should_not_be await base.Null_check_in_anonymous_type_projection_should_not_be_removed(async); AssertSql( - @"SELECT [l].[Id], [t].[c], [t].[Name], [t].[Id] + @"SELECT [l].[Id], [t].[c], [t].[Name], [t].[Id], [t].[Id0] FROM [LevelOne] AS [l] LEFT JOIN ( SELECT CASE WHEN [l1].[Id] IS NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) - END AS [c], [l1].[Name], [l0].[Id], [l0].[OneToMany_Optional_Inverse2Id] + END AS [c], [l1].[Name], [l0].[Id], [l1].[Id] AS [Id0], [l0].[OneToMany_Optional_Inverse2Id] FROM [LevelTwo] AS [l0] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Required_Id] ) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id]"); +ORDER BY [l].[Id], [t].[Id], [t].[Id0]"); } public override async Task Null_check_in_Dto_projection_should_not_be_removed(bool async) @@ -3416,17 +3416,17 @@ public override async Task Null_check_in_Dto_projection_should_not_be_removed(bo await base.Null_check_in_Dto_projection_should_not_be_removed(async); AssertSql( - @"SELECT [l].[Id], [t].[c], [t].[Name], [t].[Id] + @"SELECT [l].[Id], [t].[c], [t].[Name], [t].[Id], [t].[Id0] FROM [LevelOne] AS [l] LEFT JOIN ( SELECT CASE WHEN [l1].[Id] IS NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) - END AS [c], [l1].[Name], [l0].[Id], [l0].[OneToMany_Optional_Inverse2Id] + END AS [c], [l1].[Name], [l0].[Id], [l1].[Id] AS [Id0], [l0].[OneToMany_Optional_Inverse2Id] FROM [LevelTwo] AS [l0] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Required_Id] ) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id]"); +ORDER BY [l].[Id], [t].[Id], [t].[Id0]"); } public override async Task SelectMany_navigation_property_followed_by_select_collection_navigation(bool async) @@ -3845,7 +3845,7 @@ LEFT JOIN ( FROM [LevelTwo] AS [l0] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] ) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id]"); +ORDER BY [l].[Id], [t].[Id], [t].[Id0]"); } public override void IncludeCollection3() @@ -3857,7 +3857,7 @@ public override void IncludeCollection3() FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l1].[Id]"); +ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); } public override void IncludeCollection4() @@ -3883,7 +3883,7 @@ LEFT JOIN ( FROM [LevelTwo] AS [l0] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] ) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id]"); +ORDER BY [l].[Id], [t].[Id], [t].[Id0]"); } public override void IncludeCollection6() @@ -3899,7 +3899,7 @@ FROM [LevelTwo] AS [l0] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Optional_Id] ) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id]"); +ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t].[Id1]"); } public override void IncludeCollection6_1() @@ -3915,7 +3915,7 @@ FROM [LevelTwo] AS [l0] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Optional_Id] ) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id]"); +ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t].[Id1]"); } public override void IncludeCollection6_2() @@ -3933,7 +3933,7 @@ FROM [LevelTwo] AS [l0] LEFT JOIN [LevelThree] AS [l3] ON [l0].[Id] = [l3].[Level2_Optional_Id] LEFT JOIN [LevelFour] AS [l4] ON [l3].[Id] = [l4].[OneToMany_Optional_Inverse4Id] ) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id], [t].[Id3]"); +ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t].[Id1], [t].[Id2], [t].[Id3]"); } public override void IncludeCollection6_3() @@ -3951,7 +3951,7 @@ FROM [LevelTwo] AS [l0] LEFT JOIN [LevelThree] AS [l3] ON [l0].[Id] = [l3].[Level2_Optional_Id] LEFT JOIN [LevelFour] AS [l4] ON [l3].[Id] = [l4].[OneToMany_Optional_Inverse4Id] ) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id], [t].[Id3]"); +ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t].[Id1], [t].[Id2], [t].[Id3]"); } public override void IncludeCollection6_4() @@ -3967,7 +3967,7 @@ FROM [LevelTwo] AS [l0] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Optional_Id] ) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id1]"); +ORDER BY [l].[Id], [t].[Id1], [t].[Id], [t].[Id0]"); } public override void IncludeCollection7() @@ -3987,7 +3987,7 @@ LEFT JOIN ( FROM [LevelTwo] AS [l2] LEFT JOIN [LevelThree] AS [l3] ON [l2].[Id] = [l3].[OneToOne_Optional_PK_Inverse3Id] ) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id], [t0].[Id]"); +ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t0].[Id], [t0].[Id0]"); } public override async Task IncludeCollection8(bool async) @@ -4008,7 +4008,7 @@ SELECT COUNT(*) FROM [LevelTwo] AS [l3] LEFT JOIN [LevelThree] AS [l4] ON [l3].[Id] = [l4].[OneToOne_Optional_PK_Inverse3Id] WHERE ([l].[Id] = [l3].[OneToMany_Optional_Inverse2Id]) AND (([l4].[Name] <> N'Foo') OR [l4].[Name] IS NULL)) > 0 -ORDER BY [l].[Id], [t].[Id]"); +ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t].[Id1]"); } public override async Task Include_with_all_method_include_gets_ignored(bool isAsnc) @@ -4046,7 +4046,7 @@ FROM [LevelOne] AS [l] INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] LEFT JOIN [LevelTwo] AS [l1] ON [l].[Id] = [l1].[Level1_Optional_Id] LEFT JOIN [LevelThree] AS [l2] ON [l0].[Id] = [l2].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l0].[Id], [l2].[Id]"); +ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id]"); } public override void GroupJoin_with_navigations_in_the_result_selector() @@ -4100,9 +4100,9 @@ public override void Member_pushdown_chain_3_levels_deep_entity() @"SELECT [t4].[Id], [t4].[Level3_Optional_Id], [t4].[Level3_Required_Id], [t4].[Name], [t4].[OneToMany_Optional_Inverse4Id], [t4].[OneToMany_Optional_Self_Inverse4Id], [t4].[OneToMany_Required_Inverse4Id], [t4].[OneToMany_Required_Self_Inverse4Id], [t4].[OneToOne_Optional_PK_Inverse4Id], [t4].[OneToOne_Optional_Self4Id] FROM [LevelOne] AS [l] LEFT JOIN ( - SELECT [t3].[Id], [t3].[Level3_Optional_Id], [t3].[Level3_Required_Id], [t3].[Name], [t3].[OneToMany_Optional_Inverse4Id], [t3].[OneToMany_Optional_Self_Inverse4Id], [t3].[OneToMany_Required_Inverse4Id], [t3].[OneToMany_Required_Self_Inverse4Id], [t3].[OneToOne_Optional_PK_Inverse4Id], [t3].[OneToOne_Optional_Self4Id], [t3].[Id0], [t3].[Level1_Optional_Id] + SELECT [t3].[Id], [t3].[Level3_Optional_Id], [t3].[Level3_Required_Id], [t3].[Name], [t3].[OneToMany_Optional_Inverse4Id], [t3].[OneToMany_Optional_Self_Inverse4Id], [t3].[OneToMany_Required_Inverse4Id], [t3].[OneToMany_Required_Self_Inverse4Id], [t3].[OneToOne_Optional_PK_Inverse4Id], [t3].[OneToOne_Optional_Self4Id], [t3].[Id0], [t3].[Id00], [t3].[Level1_Optional_Id] FROM ( - SELECT [t2].[Id], [t2].[Level3_Optional_Id], [t2].[Level3_Required_Id], [t2].[Name], [t2].[OneToMany_Optional_Inverse4Id], [t2].[OneToMany_Optional_Self_Inverse4Id], [t2].[OneToMany_Required_Inverse4Id], [t2].[OneToMany_Required_Self_Inverse4Id], [t2].[OneToOne_Optional_PK_Inverse4Id], [t2].[OneToOne_Optional_Self4Id], [l0].[Id] AS [Id0], [l0].[Level1_Optional_Id], ROW_NUMBER() OVER(PARTITION BY [l0].[Level1_Optional_Id] ORDER BY [l0].[Id]) AS [row] + SELECT [t2].[Id], [t2].[Level3_Optional_Id], [t2].[Level3_Required_Id], [t2].[Name], [t2].[OneToMany_Optional_Inverse4Id], [t2].[OneToMany_Optional_Self_Inverse4Id], [t2].[OneToMany_Required_Inverse4Id], [t2].[OneToMany_Required_Self_Inverse4Id], [t2].[OneToOne_Optional_PK_Inverse4Id], [t2].[OneToOne_Optional_Self4Id], [l0].[Id] AS [Id0], [t2].[Id0] AS [Id00], [l0].[Level1_Optional_Id], ROW_NUMBER() OVER(PARTITION BY [l0].[Level1_Optional_Id] ORDER BY [l0].[Id]) AS [row] FROM [LevelTwo] AS [l0] LEFT JOIN ( SELECT [t1].[Id], [t1].[Level3_Optional_Id], [t1].[Level3_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse4Id], [t1].[OneToMany_Optional_Self_Inverse4Id], [t1].[OneToMany_Required_Inverse4Id], [t1].[OneToMany_Required_Self_Inverse4Id], [t1].[OneToOne_Optional_PK_Inverse4Id], [t1].[OneToOne_Optional_Self4Id], [t1].[Id0], [t1].[Level2_Required_Id] @@ -4235,7 +4235,7 @@ FROM [LevelTwo] AS [l0] WHERE [t0].[row] <= 1 ) AS [t1] ON [t].[Id] = [t1].[OneToMany_Required_Inverse2Id] LEFT JOIN [LevelTwo] AS [l1] ON [t].[Id] = [l1].[OneToMany_Required_Inverse2Id] -ORDER BY [t].[Id], [l1].[Id]"); +ORDER BY [t].[Id], [t1].[Id], [l1].[Id]"); } public override async Task Including_reference_navigation_and_projecting_collection_navigation(bool async) @@ -4248,7 +4248,7 @@ FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Optional_Id] LEFT JOIN [LevelTwo] AS [l2] ON [l].[Id] = [l2].[OneToMany_Required_Inverse2Id] -ORDER BY [l].[Id], [l2].[Id]"); +ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id]"); } public override async Task Including_reference_navigation_and_projecting_collection_navigation_2(bool async) @@ -4268,7 +4268,7 @@ FROM [LevelTwo] AS [l1] WHERE [t].[row] <= 1 ) AS [t0] ON [l].[Id] = [t0].[OneToMany_Required_Inverse2Id] LEFT JOIN [LevelTwo] AS [l2] ON [l].[Id] = [l2].[OneToMany_Required_Inverse2Id] -ORDER BY [l].[Id], [l2].[Id]"); +ORDER BY [l].[Id], [l0].[Id], [t0].[Id], [l2].[Id]"); } public override async Task OrderBy_collection_count_ThenBy_reference_navigation(bool async) @@ -4305,12 +4305,12 @@ public override async Task LeftJoin_with_Any_on_outer_source_and_projecting_coll @"SELECT CASE WHEN [l0].[Id] IS NULL THEN 0 ELSE [l0].[Id] -END, [l].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] +END, [l].[Id], [l0].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Required_Inverse3Id] WHERE [l].[Name] IN (N'L1 01', N'L1 02') -ORDER BY [l].[Id], [l1].[Id]"); +ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); } public override async Task Sum_with_selector_cast_using_as(bool async) @@ -4353,7 +4353,7 @@ public override async Task Select_subquery_single_nested_subquery(bool async) await base.Select_subquery_single_nested_subquery(async); AssertSql( - @"SELECT [t0].[c], [l].[Id], [l1].[Id] + @"SELECT [t0].[c], [l].[Id], [t0].[Id], [l1].[Id] FROM [LevelOne] AS [l] LEFT JOIN ( SELECT [t].[c], [t].[Id], [t].[OneToMany_Optional_Inverse2Id] @@ -4364,7 +4364,7 @@ FROM [LevelTwo] AS [l0] WHERE [t].[row] <= 1 ) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] LEFT JOIN [LevelThree] AS [l1] ON [t0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l1].[Id]"); +ORDER BY [l].[Id], [t0].[Id], [l1].[Id]"); } public override async Task Select_subquery_single_nested_subquery2(bool async) @@ -4372,10 +4372,10 @@ public override async Task Select_subquery_single_nested_subquery2(bool async) await base.Select_subquery_single_nested_subquery2(async); AssertSql( - @"SELECT [l].[Id], [t1].[c], [t1].[Id], [t1].[Id0] + @"SELECT [l].[Id], [t1].[c], [t1].[Id], [t1].[Id0], [t1].[Id1] FROM [LevelOne] AS [l] LEFT JOIN ( - SELECT [t0].[c], [l0].[Id], [l2].[Id] AS [Id0], [l0].[OneToMany_Optional_Inverse2Id] + SELECT [t0].[c], [l0].[Id], [t0].[Id] AS [Id0], [l2].[Id] AS [Id1], [l0].[OneToMany_Optional_Inverse2Id] FROM [LevelTwo] AS [l0] LEFT JOIN ( SELECT [t].[c], [t].[Id], [t].[OneToMany_Optional_Inverse3Id] @@ -4387,7 +4387,7 @@ FROM [LevelThree] AS [l1] ) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] LEFT JOIN [LevelFour] AS [l2] ON [t0].[Id] = [l2].[OneToMany_Optional_Inverse4Id] ) AS [t1] ON [l].[Id] = [t1].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t1].[Id], [t1].[Id0]"); +ORDER BY [l].[Id], [t1].[Id], [t1].[Id0], [t1].[Id1]"); } public override async Task SelectMany_with_outside_reference_to_joined_table_correctly_translated_to_apply(bool async) @@ -4633,7 +4633,7 @@ FROM [LevelThree] AS [l1] ORDER BY [l1].[Name] OFFSET 1 ROWS FETCH NEXT 3 ROWS ONLY ) AS [t] -ORDER BY [l].[Id], [t].[Name], [t].[Id]"); +ORDER BY [l].[Id], [l0].[Id], [t].[Name], [t].[Id]"); } public override async Task Filtered_include_after_reference_navigation(bool async) @@ -4651,7 +4651,7 @@ FROM [LevelThree] AS [l1] ORDER BY [l1].[Name] OFFSET 1 ROWS FETCH NEXT 3 ROWS ONLY ) AS [t] -ORDER BY [l].[Id], [t].[Name], [t].[Id]"); +ORDER BY [l].[Id], [l0].[Id], [t].[Name], [t].[Id]"); } public override async Task Filtered_include_after_different_filtered_include_same_level(bool async) @@ -4737,7 +4737,7 @@ ORDER BY [l0].[Id] LEFT JOIN [LevelThree] AS [l1] ON [t].[Id] = [l1].[Level2_Required_Id] LEFT JOIN [LevelThree] AS [l2] ON [t].[Id] = [l2].[OneToMany_Optional_Inverse3Id] ) AS [t0] -ORDER BY [l].[Id], [t0].[Id], [t0].[Id1]"); +ORDER BY [l].[Id], [t0].[Id], [t0].[Id0], [t0].[Id1]"); } public override async Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(bool async) @@ -4758,7 +4758,7 @@ ORDER BY [l0].[Id] LEFT JOIN [LevelThree] AS [l1] ON [t].[Id] = [l1].[Level2_Required_Id] LEFT JOIN [LevelThree] AS [l2] ON [t].[Id] = [l2].[OneToMany_Optional_Inverse3Id] ) AS [t0] -ORDER BY [l].[Id], [t0].[Id], [t0].[Id1]"); +ORDER BY [l].[Id], [t0].[Id], [t0].[Id0], [t0].[Id1]"); } public override async Task Filtered_include_and_non_filtered_include_on_same_navigation1(bool async) @@ -4815,7 +4815,7 @@ FROM [LevelFour] AS [l2] WHERE [l2].[Id] > 1 ) AS [t0] ON [l1].[Id] = [t0].[OneToMany_Optional_Inverse4Id] ) AS [t1] -ORDER BY [l].[Id], [t1].[Id], [t1].[Id1]"); +ORDER BY [l].[Id], [t1].[Id], [t1].[Id0], [t1].[Id1]"); } public override async Task Filtered_include_complex_three_level_with_middle_having_filter1(bool async) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs index ed0a2b83f0d..77b7b7a52fd 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs @@ -43,7 +43,7 @@ public override async Task Include_multiple_one_to_one_and_one_to_many(bool asyn FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -ORDER BY [t].[Id], [w].[Id]"); +ORDER BY [t].[Id], [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task Include_multiple_one_to_one_optional_and_one_to_one_required(bool async) @@ -1739,7 +1739,7 @@ public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesc FROM [Gears] AS [g] LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [w].[Id]"); +ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [w].[Id]"); } public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result2() @@ -1752,7 +1752,7 @@ public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesc FROM [Gears] AS [g] LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] LEFT JOIN [Weapons] AS [w] ON [g0].[FullName] = [w].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [w].[Id]"); +ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [w].[Id]"); } public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result3(bool async) @@ -1766,7 +1766,7 @@ FROM [Gears] AS [g] LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] LEFT JOIN [Weapons] AS [w] ON [g0].[FullName] = [w].[OwnerFullName] LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [w].[Id], [w0].[Id]"); +ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [w].[Id], [w0].[Id]"); } public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result4(bool async) @@ -1829,7 +1829,7 @@ FROM [Gears] AS [g0] ) AS [t] ON [g].[LeaderNickname] = [t].[Nickname] LEFT JOIN [Weapons] AS [w] ON [t].[FullName] = [w].[OwnerFullName] LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [w].[Id], [w0].[Id]"); +ORDER BY [g].[Nickname], [g].[SquadId], [t].[Nickname], [t].[SquadId], [w].[Id], [w0].[Id]"); } public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_conditional_result(bool async) @@ -3090,7 +3090,7 @@ FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [t] ON [f].[CommanderName] = [t].[Name] LEFT JOIN [LocustLeaders] AS [l0] ON [f].[Id] = [l0].[LocustHordeId] -ORDER BY [f].[Name], [f].[Id], [l0].[Name]"); +ORDER BY [f].[Name], [f].[Id], [t].[Name], [l0].[Name]"); } public override async Task Distinct_on_subquery_doesnt_get_lifted(bool async) @@ -3219,7 +3219,7 @@ public override async Task Project_collection_navigation_with_inheritance1(bool await base.Project_collection_navigation_with_inheritance1(async); AssertSql( - @"SELECT [f].[Id], [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId] + @"SELECT [f].[Id], [t].[Name], [f0].[Id], [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId] FROM [Factions] AS [f] LEFT JOIN ( SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] @@ -3228,7 +3228,7 @@ FROM [LocustLeaders] AS [l] ) AS [t] ON [f].[CommanderName] = [t].[Name] LEFT JOIN [Factions] AS [f0] ON [t].[Name] = [f0].[CommanderName] LEFT JOIN [LocustLeaders] AS [l0] ON [f0].[Id] = [l0].[LocustHordeId] -ORDER BY [f].[Id], [l0].[Name]"); +ORDER BY [f].[Id], [t].[Name], [f0].[Id], [l0].[Name]"); } public override async Task Project_collection_navigation_with_inheritance2(bool async) @@ -3236,7 +3236,7 @@ public override async Task Project_collection_navigation_with_inheritance2(bool await base.Project_collection_navigation_with_inheritance2(async); AssertSql( - @"SELECT [f].[Id], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] + @"SELECT [f].[Id], [t].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Factions] AS [f] LEFT JOIN ( SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] @@ -3245,7 +3245,7 @@ FROM [LocustLeaders] AS [l] ) AS [t] ON [f].[CommanderName] = [t].[Name] LEFT JOIN [Gears] AS [g] ON ([t].[DefeatedByNickname] = [g].[Nickname]) AND ([t].[DefeatedBySquadId] = [g].[SquadId]) LEFT JOIN [Gears] AS [g0] ON (([g].[Nickname] = [g0].[LeaderNickname]) OR ([g].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND ([g].[SquadId] = [g0].[LeaderSquadId]) -ORDER BY [f].[Id], [g0].[Nickname], [g0].[SquadId]"); +ORDER BY [f].[Id], [t].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Project_collection_navigation_with_inheritance3(bool async) @@ -3253,7 +3253,7 @@ public override async Task Project_collection_navigation_with_inheritance3(bool await base.Project_collection_navigation_with_inheritance3(async); AssertSql( - @"SELECT [f].[Id], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] + @"SELECT [f].[Id], [t].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Factions] AS [f] LEFT JOIN ( SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] @@ -3263,7 +3263,7 @@ FROM [LocustLeaders] AS [l] LEFT JOIN [Gears] AS [g] ON ([t].[DefeatedByNickname] = [g].[Nickname]) AND ([t].[DefeatedBySquadId] = [g].[SquadId]) LEFT JOIN [Gears] AS [g0] ON (([g].[Nickname] = [g0].[LeaderNickname]) OR ([g].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND ([g].[SquadId] = [g0].[LeaderSquadId]) WHERE [f].[Discriminator] = N'LocustHorde' -ORDER BY [f].[Id], [g0].[Nickname], [g0].[SquadId]"); +ORDER BY [f].[Id], [t].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Include_reference_on_derived_type_using_string(bool async) @@ -3300,7 +3300,7 @@ LEFT JOIN ( FROM [Gears] AS [g0] INNER JOIN [Cities] AS [c] ON [g0].[CityOfBirthName] = [c].[Name] ) AS [t] ON (([g].[Nickname] = [t].[LeaderNickname]) OR ([g].[Nickname] IS NULL AND [t].[LeaderNickname] IS NULL)) AND ([g].[SquadId] = [t].[LeaderSquadId]) -ORDER BY [l].[Name], [t].[Nickname], [t].[SquadId], [t].[Name]"); +ORDER BY [l].[Name], [g].[Nickname], [g].[SquadId], [t].[Nickname], [t].[SquadId], [t].[Name]"); } public override async Task Include_reference_on_derived_type_using_lambda(bool async) @@ -3375,7 +3375,7 @@ public override async Task Include_base_navigation_on_derived_entity(bool async) FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [w].[Id]"); +ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id], [w].[Id]"); } public override async Task ThenInclude_collection_on_derived_after_base_reference(bool async) @@ -3387,7 +3387,7 @@ public override async Task ThenInclude_collection_on_derived_after_base_referenc FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -ORDER BY [t].[Id], [w].[Id]"); +ORDER BY [t].[Id], [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task ThenInclude_collection_on_derived_after_derived_reference(bool async) @@ -3404,7 +3404,7 @@ FROM [LocustLeaders] AS [l] ) AS [t] ON [f].[CommanderName] = [t].[Name] LEFT JOIN [Gears] AS [g] ON ([t].[DefeatedByNickname] = [g].[Nickname]) AND ([t].[DefeatedBySquadId] = [g].[SquadId]) LEFT JOIN [Gears] AS [g0] ON (([g].[Nickname] = [g0].[LeaderNickname]) OR ([g].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND ([g].[SquadId] = [g0].[LeaderSquadId]) -ORDER BY [f].[Id], [g0].[Nickname], [g0].[SquadId]"); +ORDER BY [f].[Id], [t].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task ThenInclude_collection_on_derived_after_derived_collection(bool async) @@ -3434,7 +3434,7 @@ LEFT JOIN ( FROM [LocustLeaders] AS [l] LEFT JOIN [Gears] AS [g] ON ([l].[DefeatedByNickname] = [g].[Nickname]) AND ([l].[DefeatedBySquadId] = [g].[SquadId]) ) AS [t] ON [f].[Id] = [t].[LocustHordeId] -ORDER BY [f].[Id], [t].[Name]"); +ORDER BY [f].[Id], [t].[Name], [t].[Nickname], [t].[SquadId]"); } public override async Task Multiple_derived_included_on_one_method(bool async) @@ -3451,7 +3451,7 @@ FROM [LocustLeaders] AS [l] ) AS [t] ON [f].[CommanderName] = [t].[Name] LEFT JOIN [Gears] AS [g] ON ([t].[DefeatedByNickname] = [g].[Nickname]) AND ([t].[DefeatedBySquadId] = [g].[SquadId]) LEFT JOIN [Gears] AS [g0] ON (([g].[Nickname] = [g0].[LeaderNickname]) OR ([g].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND ([g].[SquadId] = [g0].[LeaderSquadId]) -ORDER BY [f].[Id], [g0].[Nickname], [g0].[SquadId]"); +ORDER BY [f].[Id], [t].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Include_on_derived_multi_level(bool async) @@ -3849,12 +3849,12 @@ public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_ await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery(async); AssertSql( - @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t0].[Id], [t0].[AmmunitionType], [t0].[IsAutomatic], [t0].[Name], [t0].[OwnerFullName], [t0].[SynergyWithId] + @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [g0].[Nickname], [g0].[SquadId], [t0].[Id], [t0].[AmmunitionType], [t0].[IsAutomatic], [t0].[Name], [t0].[OwnerFullName], [t0].[SynergyWithId], [t0].[Nickname], [t0].[SquadId] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) LEFT JOIN [Gears] AS [g0] ON ([t].[GearNickName] = [g0].[Nickname]) AND ([t].[GearSquadId] = [g0].[SquadId]) LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g1].[Nickname] + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g1].[Nickname], [g1].[SquadId] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g1] ON [w].[OwnerFullName] = [g1].[FullName] ) AS [t0] ON [g0].[FullName] = [t0].[OwnerFullName] @@ -3862,7 +3862,7 @@ FROM [Weapons] AS [w] SELECT 1 FROM [Gears] AS [g2] WHERE ([g].[Nickname] = [g2].[LeaderNickname]) AND ([g].[SquadId] = [g2].[LeaderSquadId])) -ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t0].[IsAutomatic], [t0].[Nickname] DESC, [t0].[Id]"); +ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [g0].[Nickname], [g0].[SquadId], [t0].[IsAutomatic], [t0].[Nickname] DESC, [t0].[Id], [t0].[SquadId]"); } public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_duplicated_orderings( @@ -3871,12 +3871,12 @@ public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_ await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_duplicated_orderings(async); AssertSql( - @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t0].[Id], [t0].[AmmunitionType], [t0].[IsAutomatic], [t0].[Name], [t0].[OwnerFullName], [t0].[SynergyWithId] + @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [g0].[Nickname], [g0].[SquadId], [t0].[Id], [t0].[AmmunitionType], [t0].[IsAutomatic], [t0].[Name], [t0].[OwnerFullName], [t0].[SynergyWithId], [t0].[Nickname], [t0].[SquadId] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) LEFT JOIN [Gears] AS [g0] ON ([t].[GearNickName] = [g0].[Nickname]) AND ([t].[GearSquadId] = [g0].[SquadId]) LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g1].[Nickname] + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g1].[Nickname], [g1].[SquadId] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g1] ON [w].[OwnerFullName] = [g1].[FullName] ) AS [t0] ON [g0].[FullName] = [t0].[OwnerFullName] @@ -3884,7 +3884,7 @@ FROM [Weapons] AS [w] SELECT 1 FROM [Gears] AS [g2] WHERE ([g].[Nickname] = [g2].[LeaderNickname]) AND ([g].[SquadId] = [g2].[LeaderSquadId])) -ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t0].[IsAutomatic], [t0].[Nickname] DESC, [t0].[Id]"); +ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [g0].[Nickname], [g0].[SquadId], [t0].[IsAutomatic], [t0].[Nickname] DESC, [t0].[Id], [t0].[SquadId]"); } public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_complex_orderings( @@ -3893,12 +3893,12 @@ public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_ await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_complex_orderings(async); AssertSql( - @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t0].[Id], [t0].[AmmunitionType], [t0].[IsAutomatic], [t0].[Name], [t0].[OwnerFullName], [t0].[SynergyWithId] + @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [g0].[Nickname], [g0].[SquadId], [t0].[Id], [t0].[AmmunitionType], [t0].[IsAutomatic], [t0].[Name], [t0].[OwnerFullName], [t0].[SynergyWithId], [t0].[Nickname], [t0].[SquadId] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) LEFT JOIN [Gears] AS [g0] ON ([t].[GearNickName] = [g0].[Nickname]) AND ([t].[GearSquadId] = [g0].[SquadId]) LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], ( + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [g1].[Nickname], [g1].[SquadId], ( SELECT COUNT(*) FROM [Weapons] AS [w] WHERE [g1].[FullName] IS NOT NULL AND ([g1].[FullName] = [w].[OwnerFullName])) AS [c] @@ -3909,7 +3909,7 @@ FROM [Weapons] AS [w0] SELECT 1 FROM [Gears] AS [g2] WHERE ([g].[Nickname] = [g2].[LeaderNickname]) AND ([g].[SquadId] = [g2].[LeaderSquadId])) -ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t0].[Id] DESC, [t0].[c]"); +ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [g0].[Nickname], [g0].[SquadId], [t0].[Id] DESC, [t0].[c], [t0].[Nickname], [t0].[SquadId]"); } public override async Task Correlated_collections_multiple_nested_complex_collections(bool async) @@ -3917,15 +3917,15 @@ public override async Task Correlated_collections_multiple_nested_complex_collec await base.Correlated_collections_multiple_nested_complex_collections(async); AssertSql( - @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t1].[FullName], [t1].[Nickname], [t1].[SquadId], [t1].[Id], [t1].[Name], [t1].[IsAutomatic], [t1].[Id0], [t1].[Nickname0], [t1].[HasSoulPatch], [t1].[SquadId0], [t2].[Id], [t2].[AmmunitionType], [t2].[IsAutomatic], [t2].[Name], [t2].[OwnerFullName], [t2].[SynergyWithId] + @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [g0].[Nickname], [g0].[SquadId], [t1].[FullName], [t1].[Nickname], [t1].[SquadId], [t1].[Id], [t1].[Nickname0], [t1].[SquadId0], [t1].[Id0], [t1].[Name], [t1].[IsAutomatic], [t1].[Id1], [t1].[Nickname00], [t1].[HasSoulPatch], [t1].[SquadId00], [t2].[Id], [t2].[AmmunitionType], [t2].[IsAutomatic], [t2].[Name], [t2].[OwnerFullName], [t2].[SynergyWithId], [t2].[Nickname], [t2].[SquadId] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) LEFT JOIN [Gears] AS [g0] ON ([t].[GearNickName] = [g0].[Nickname]) AND ([t].[GearSquadId] = [g0].[SquadId]) LEFT JOIN ( - SELECT [g1].[FullName], [g1].[Nickname], [g1].[SquadId], [t0].[Id], [t0].[Name], [t0].[IsAutomatic], [t0].[Id0], [t0].[Nickname] AS [Nickname0], [t0].[HasSoulPatch], [t0].[SquadId] AS [SquadId0], [g1].[Rank], [t0].[IsAutomatic0], [g1].[LeaderNickname], [g1].[LeaderSquadId] + SELECT [g1].[FullName], [g1].[Nickname], [g1].[SquadId], [t0].[Id], [t0].[Nickname] AS [Nickname0], [t0].[SquadId] AS [SquadId0], [t0].[Id0], [t0].[Name], [t0].[IsAutomatic], [t0].[Id1], [t0].[Nickname0] AS [Nickname00], [t0].[HasSoulPatch], [t0].[SquadId0] AS [SquadId00], [g1].[Rank], [t0].[IsAutomatic0], [g1].[LeaderNickname], [g1].[LeaderSquadId] FROM [Gears] AS [g1] LEFT JOIN ( - SELECT [w].[Id], [w0].[Name], [w0].[IsAutomatic], [w0].[Id] AS [Id0], [g3].[Nickname], [g3].[HasSoulPatch], [g3].[SquadId], [w].[IsAutomatic] AS [IsAutomatic0], [w].[OwnerFullName] + SELECT [w].[Id], [g2].[Nickname], [g2].[SquadId], [s].[Id] AS [Id0], [w0].[Name], [w0].[IsAutomatic], [w0].[Id] AS [Id1], [g3].[Nickname] AS [Nickname0], [g3].[HasSoulPatch], [g3].[SquadId] AS [SquadId0], [w].[IsAutomatic] AS [IsAutomatic0], [w].[OwnerFullName] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g2] ON [w].[OwnerFullName] = [g2].[FullName] LEFT JOIN [Squads] AS [s] ON [g2].[SquadId] = [s].[Id] @@ -3936,7 +3936,7 @@ FROM [Weapons] AS [w] WHERE [g1].[FullName] <> N'Foo' ) AS [t1] ON ([g].[Nickname] = [t1].[LeaderNickname]) AND ([g].[SquadId] = [t1].[LeaderSquadId]) LEFT JOIN ( - SELECT [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [g4].[Nickname] + SELECT [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [g4].[Nickname], [g4].[SquadId] FROM [Weapons] AS [w1] LEFT JOIN [Gears] AS [g4] ON [w1].[OwnerFullName] = [g4].[FullName] ) AS [t2] ON [g0].[FullName] = [t2].[OwnerFullName] @@ -3944,7 +3944,7 @@ FROM [Weapons] AS [w1] SELECT 1 FROM [Gears] AS [g5] WHERE ([g].[Nickname] = [g5].[LeaderNickname]) AND ([g].[SquadId] = [g5].[LeaderSquadId])) -ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t1].[Rank], [t1].[Nickname], [t1].[SquadId], [t1].[IsAutomatic0], [t1].[Id], [t1].[Id0], [t1].[Nickname0], [t1].[SquadId0], [t2].[IsAutomatic], [t2].[Nickname] DESC, [t2].[Id]"); +ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [g0].[Nickname], [g0].[SquadId], [t1].[Rank], [t1].[Nickname], [t1].[SquadId], [t1].[IsAutomatic0], [t1].[Id], [t1].[Nickname0], [t1].[SquadId0], [t1].[Id0], [t1].[Id1], [t1].[Nickname00], [t1].[SquadId00], [t2].[IsAutomatic], [t2].[Nickname] DESC, [t2].[Id], [t2].[SquadId]"); } public override async Task Correlated_collections_inner_subquery_selector_references_outer_qsre(bool async) @@ -4126,12 +4126,12 @@ public override async Task Correlated_collections_on_left_join_with_predicate(bo await base.Correlated_collections_on_left_join_with_predicate(async); AssertSql( - @"SELECT [g].[Nickname], [t].[Id], [w].[Name], [w].[Id] + @"SELECT [g].[Nickname], [t].[Id], [g].[SquadId], [w].[Name], [w].[Id] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] WHERE [g].[HasSoulPatch] <> CAST(1 AS bit) -ORDER BY [t].[Id], [w].[Id]"); +ORDER BY [t].[Id], [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task Correlated_collections_on_left_join_with_null_value(bool async) @@ -4139,11 +4139,11 @@ public override async Task Correlated_collections_on_left_join_with_null_value(b await base.Correlated_collections_on_left_join_with_null_value(async); AssertSql( - @"SELECT [t].[Id], [w].[Name], [w].[Id] + @"SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [w].[Name], [w].[Id] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -ORDER BY [t].[Note], [t].[Id], [w].[Id]"); +ORDER BY [t].[Note], [t].[Id], [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task Correlated_collections_left_join_with_self_reference(bool async) @@ -4151,7 +4151,7 @@ public override async Task Correlated_collections_left_join_with_self_reference( await base.Correlated_collections_left_join_with_self_reference(async); AssertSql( - @"SELECT [t].[Note], [t].[Id], [g0].[FullName], [g0].[Nickname], [g0].[SquadId] + @"SELECT [t].[Note], [t].[Id], [t0].[Nickname], [t0].[SquadId], [g0].[FullName], [g0].[Nickname], [g0].[SquadId] FROM [Tags] AS [t] LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] @@ -4159,7 +4159,7 @@ FROM [Gears] AS [g] WHERE [g].[Discriminator] = N'Officer' ) AS [t0] ON [t].[GearNickName] = [t0].[Nickname] LEFT JOIN [Gears] AS [g0] ON (([t0].[Nickname] = [g0].[LeaderNickname]) OR ([t0].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND ([t0].[SquadId] = [g0].[LeaderSquadId]) -ORDER BY [t].[Id], [g0].[Nickname], [g0].[SquadId]"); +ORDER BY [t].[Id], [t0].[Nickname], [t0].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Correlated_collections_deeply_nested_left_join(bool async) @@ -4167,7 +4167,7 @@ public override async Task Correlated_collections_deeply_nested_left_join(bool a await base.Correlated_collections_deeply_nested_left_join(async); AssertSql( - @"SELECT [t].[Id], [t1].[Nickname], [t1].[SquadId], [t1].[Id], [t1].[AmmunitionType], [t1].[IsAutomatic], [t1].[Name], [t1].[OwnerFullName], [t1].[SynergyWithId] + @"SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [s].[Id], [t1].[Nickname], [t1].[SquadId], [t1].[Id], [t1].[AmmunitionType], [t1].[IsAutomatic], [t1].[Name], [t1].[OwnerFullName], [t1].[SynergyWithId] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] @@ -4181,7 +4181,7 @@ FROM [Weapons] AS [w] ) AS [t0] ON [g0].[FullName] = [t0].[OwnerFullName] WHERE [g0].[HasSoulPatch] = CAST(1 AS bit) ) AS [t1] ON [s].[Id] = [t1].[SquadId] -ORDER BY [t].[Note], [g].[Nickname] DESC, [t].[Id], [t1].[Nickname], [t1].[SquadId], [t1].[Id]"); +ORDER BY [t].[Note], [g].[Nickname] DESC, [t].[Id], [g].[SquadId], [s].[Id], [t1].[Nickname], [t1].[SquadId], [t1].[Id]"); } public override async Task Correlated_collections_from_left_join_with_additional_elements_projected_of_that_join(bool async) @@ -4189,7 +4189,7 @@ public override async Task Correlated_collections_from_left_join_with_additional await base.Correlated_collections_from_left_join_with_additional_elements_projected_of_that_join(async); AssertSql( - @"SELECT [w].[Id], [t0].[Rank], [t0].[Nickname], [t0].[SquadId], [t0].[Id], [t0].[AmmunitionType], [t0].[IsAutomatic], [t0].[Name], [t0].[OwnerFullName], [t0].[SynergyWithId] + @"SELECT [w].[Id], [g].[Nickname], [g].[SquadId], [s].[Id], [t0].[Rank], [t0].[Nickname], [t0].[SquadId], [t0].[Id], [t0].[AmmunitionType], [t0].[IsAutomatic], [t0].[Name], [t0].[OwnerFullName], [t0].[SynergyWithId] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] @@ -4202,7 +4202,7 @@ FROM [Weapons] AS [w0] WHERE [w0].[IsAutomatic] <> CAST(1 AS bit) ) AS [t] ON [g0].[FullName] = [t].[OwnerFullName] ) AS [t0] ON [s].[Id] = [t0].[SquadId] -ORDER BY [w].[Name], [w].[Id], [t0].[FullName] DESC, [t0].[Nickname], [t0].[SquadId], [t0].[Id]"); +ORDER BY [w].[Name], [w].[Id], [g].[Nickname], [g].[SquadId], [s].[Id], [t0].[FullName] DESC, [t0].[Nickname], [t0].[SquadId], [t0].[Id]"); } public override async Task Correlated_collections_complex_scenario1(bool async) @@ -4210,16 +4210,16 @@ public override async Task Correlated_collections_complex_scenario1(bool async) await base.Correlated_collections_complex_scenario1(async); AssertSql( - @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [t].[Nickname], [t].[HasSoulPatch], [t].[SquadId] + @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [t].[Nickname], [t].[SquadId], [t].[Id0], [t].[Nickname0], [t].[HasSoulPatch], [t].[SquadId0] FROM [Gears] AS [g] LEFT JOIN ( - SELECT [w].[Id], [g1].[Nickname], [g1].[HasSoulPatch], [g1].[SquadId], [w].[OwnerFullName] + SELECT [w].[Id], [g0].[Nickname], [g0].[SquadId], [s].[Id] AS [Id0], [g1].[Nickname] AS [Nickname0], [g1].[HasSoulPatch], [g1].[SquadId] AS [SquadId0], [w].[OwnerFullName] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g0] ON [w].[OwnerFullName] = [g0].[FullName] LEFT JOIN [Squads] AS [s] ON [g0].[SquadId] = [s].[Id] LEFT JOIN [Gears] AS [g1] ON [s].[Id] = [g1].[SquadId] ) AS [t] ON [g].[FullName] = [t].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id], [t].[Nickname], [t].[SquadId]"); +ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id], [t].[Nickname], [t].[SquadId], [t].[Id0], [t].[Nickname0], [t].[SquadId0]"); } public override async Task Correlated_collections_complex_scenario2(bool async) @@ -4227,13 +4227,13 @@ public override async Task Correlated_collections_complex_scenario2(bool async) await base.Correlated_collections_complex_scenario2(async); AssertSql( - @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t0].[FullName], [t0].[Nickname], [t0].[SquadId], [t0].[Id], [t0].[Nickname0], [t0].[HasSoulPatch], [t0].[SquadId0] + @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t0].[FullName], [t0].[Nickname], [t0].[SquadId], [t0].[Id], [t0].[Nickname0], [t0].[SquadId0], [t0].[Id0], [t0].[Nickname00], [t0].[HasSoulPatch], [t0].[SquadId00] FROM [Gears] AS [g] LEFT JOIN ( - SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [t].[Id], [t].[Nickname] AS [Nickname0], [t].[HasSoulPatch], [t].[SquadId] AS [SquadId0], [g0].[LeaderNickname], [g0].[LeaderSquadId] + SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [t].[Id], [t].[Nickname] AS [Nickname0], [t].[SquadId] AS [SquadId0], [t].[Id0], [t].[Nickname0] AS [Nickname00], [t].[HasSoulPatch], [t].[SquadId0] AS [SquadId00], [g0].[LeaderNickname], [g0].[LeaderSquadId] FROM [Gears] AS [g0] LEFT JOIN ( - SELECT [w].[Id], [g2].[Nickname], [g2].[HasSoulPatch], [g2].[SquadId], [w].[OwnerFullName] + SELECT [w].[Id], [g1].[Nickname], [g1].[SquadId], [s].[Id] AS [Id0], [g2].[Nickname] AS [Nickname0], [g2].[HasSoulPatch], [g2].[SquadId] AS [SquadId0], [w].[OwnerFullName] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g1] ON [w].[OwnerFullName] = [g1].[FullName] LEFT JOIN [Squads] AS [s] ON [g1].[SquadId] = [s].[Id] @@ -4241,7 +4241,7 @@ FROM [Weapons] AS [w] ) AS [t] ON [g0].[FullName] = [t].[OwnerFullName] ) AS [t0] ON ([g].[Nickname] = [t0].[LeaderNickname]) AND ([g].[SquadId] = [t0].[LeaderSquadId]) WHERE [g].[Discriminator] = N'Officer' -ORDER BY [g].[Nickname], [g].[SquadId], [t0].[Nickname], [t0].[SquadId], [t0].[Id], [t0].[Nickname0], [t0].[SquadId0]"); +ORDER BY [g].[Nickname], [g].[SquadId], [t0].[Nickname], [t0].[SquadId], [t0].[Id], [t0].[Nickname0], [t0].[SquadId0], [t0].[Id0], [t0].[Nickname00], [t0].[SquadId00]"); } public override async Task Correlated_collections_with_funky_orderby_complex_scenario1(bool async) @@ -4249,16 +4249,16 @@ public override async Task Correlated_collections_with_funky_orderby_complex_sce await base.Correlated_collections_with_funky_orderby_complex_scenario1(async); AssertSql( - @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [t].[Nickname], [t].[HasSoulPatch], [t].[SquadId] + @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [t].[Nickname], [t].[SquadId], [t].[Id0], [t].[Nickname0], [t].[HasSoulPatch], [t].[SquadId0] FROM [Gears] AS [g] LEFT JOIN ( - SELECT [w].[Id], [g1].[Nickname], [g1].[HasSoulPatch], [g1].[SquadId], [w].[OwnerFullName] + SELECT [w].[Id], [g0].[Nickname], [g0].[SquadId], [s].[Id] AS [Id0], [g1].[Nickname] AS [Nickname0], [g1].[HasSoulPatch], [g1].[SquadId] AS [SquadId0], [w].[OwnerFullName] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g0] ON [w].[OwnerFullName] = [g0].[FullName] LEFT JOIN [Squads] AS [s] ON [g0].[SquadId] = [s].[Id] LEFT JOIN [Gears] AS [g1] ON [s].[Id] = [g1].[SquadId] ) AS [t] ON [g].[FullName] = [t].[OwnerFullName] -ORDER BY [g].[FullName], [g].[Nickname] DESC, [g].[SquadId], [t].[Id], [t].[Nickname], [t].[SquadId]"); +ORDER BY [g].[FullName], [g].[Nickname] DESC, [g].[SquadId], [t].[Id], [t].[Nickname], [t].[SquadId], [t].[Id0], [t].[Nickname0], [t].[SquadId0]"); } public override async Task Correlated_collections_with_funky_orderby_complex_scenario2(bool async) @@ -4266,13 +4266,13 @@ public override async Task Correlated_collections_with_funky_orderby_complex_sce await base.Correlated_collections_with_funky_orderby_complex_scenario2(async); AssertSql( - @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t0].[FullName], [t0].[Nickname], [t0].[SquadId], [t0].[Id], [t0].[Nickname0], [t0].[HasSoulPatch], [t0].[SquadId0] + @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t0].[FullName], [t0].[Nickname], [t0].[SquadId], [t0].[Id], [t0].[Nickname0], [t0].[SquadId0], [t0].[Id0], [t0].[Nickname00], [t0].[HasSoulPatch], [t0].[SquadId00] FROM [Gears] AS [g] LEFT JOIN ( - SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [t].[Id], [t].[Nickname] AS [Nickname0], [t].[HasSoulPatch], [t].[SquadId] AS [SquadId0], [g0].[HasSoulPatch] AS [HasSoulPatch0], [t].[IsAutomatic], [t].[Name], [g0].[LeaderNickname], [g0].[LeaderSquadId] + SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [t].[Id], [t].[Nickname] AS [Nickname0], [t].[SquadId] AS [SquadId0], [t].[Id0], [t].[Nickname0] AS [Nickname00], [t].[HasSoulPatch], [t].[SquadId0] AS [SquadId00], [g0].[HasSoulPatch] AS [HasSoulPatch0], [t].[IsAutomatic], [t].[Name], [g0].[LeaderNickname], [g0].[LeaderSquadId] FROM [Gears] AS [g0] LEFT JOIN ( - SELECT [w].[Id], [g2].[Nickname], [g2].[HasSoulPatch], [g2].[SquadId], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName] + SELECT [w].[Id], [g1].[Nickname], [g1].[SquadId], [s].[Id] AS [Id0], [g2].[Nickname] AS [Nickname0], [g2].[HasSoulPatch], [g2].[SquadId] AS [SquadId0], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g1] ON [w].[OwnerFullName] = [g1].[FullName] LEFT JOIN [Squads] AS [s] ON [g1].[SquadId] = [s].[Id] @@ -4280,7 +4280,7 @@ FROM [Weapons] AS [w] ) AS [t] ON [g0].[FullName] = [t].[OwnerFullName] ) AS [t0] ON ([g].[Nickname] = [t0].[LeaderNickname]) AND ([g].[SquadId] = [t0].[LeaderSquadId]) WHERE [g].[Discriminator] = N'Officer' -ORDER BY [g].[HasSoulPatch], [g].[LeaderNickname], [g].[FullName], [g].[Nickname], [g].[SquadId], [t0].[FullName], [t0].[HasSoulPatch0] DESC, [t0].[Nickname], [t0].[SquadId], [t0].[IsAutomatic], [t0].[Name] DESC, [t0].[Id], [t0].[Nickname0], [t0].[SquadId0]"); +ORDER BY [g].[HasSoulPatch], [g].[LeaderNickname], [g].[FullName], [g].[Nickname], [g].[SquadId], [t0].[FullName], [t0].[HasSoulPatch0] DESC, [t0].[Nickname], [t0].[SquadId], [t0].[IsAutomatic], [t0].[Name] DESC, [t0].[Id], [t0].[Nickname0], [t0].[SquadId0], [t0].[Id0], [t0].[Nickname00], [t0].[SquadId00]"); } public override async Task Correlated_collection_with_top_level_FirstOrDefault(bool async) @@ -4374,16 +4374,16 @@ public override async Task Include_on_derived_type_with_order_by_and_paging(bool AssertSql( @"@__p_0='10' -SELECT [t0].[Name], [t0].[Discriminator], [t0].[LocustHordeId], [t0].[ThreatLevel], [t0].[ThreatLevelByte], [t0].[ThreatLevelNullableByte], [t0].[DefeatedByNickname], [t0].[DefeatedBySquadId], [t0].[HighCommandId], [t0].[Nickname], [t0].[SquadId], [t0].[AssignedCityName], [t0].[CityOfBirthName], [t0].[Discriminator0], [t0].[FullName], [t0].[HasSoulPatch], [t0].[LeaderNickname], [t0].[LeaderSquadId], [t0].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [t0].[Name], [t0].[Discriminator], [t0].[LocustHordeId], [t0].[ThreatLevel], [t0].[ThreatLevelByte], [t0].[ThreatLevelNullableByte], [t0].[DefeatedByNickname], [t0].[DefeatedBySquadId], [t0].[HighCommandId], [t0].[Nickname], [t0].[SquadId], [t0].[AssignedCityName], [t0].[CityOfBirthName], [t0].[Discriminator0], [t0].[FullName], [t0].[HasSoulPatch], [t0].[LeaderNickname], [t0].[LeaderSquadId], [t0].[Rank], [t0].[Id], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM ( - SELECT TOP(@__p_0) [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator] AS [Discriminator0], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Note] + SELECT TOP(@__p_0) [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator] AS [Discriminator0], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Id], [t].[Note] FROM [LocustLeaders] AS [l] LEFT JOIN [Gears] AS [g] ON ([l].[DefeatedByNickname] = [g].[Nickname]) AND ([l].[DefeatedBySquadId] = [g].[SquadId]) LEFT JOIN [Tags] AS [t] ON (([g].[Nickname] = [t].[GearNickName]) OR ([g].[Nickname] IS NULL AND [t].[GearNickName] IS NULL)) AND (([g].[SquadId] = [t].[GearSquadId]) OR ([g].[SquadId] IS NULL AND [t].[GearSquadId] IS NULL)) ORDER BY [t].[Note] ) AS [t0] LEFT JOIN [Weapons] AS [w] ON [t0].[FullName] = [w].[OwnerFullName] -ORDER BY [t0].[Note], [t0].[Name], [w].[Id]"); +ORDER BY [t0].[Note], [t0].[Name], [t0].[Nickname], [t0].[SquadId], [t0].[Id], [w].[Id]"); } public override async Task Select_required_navigation_on_derived_type(bool async) @@ -4454,15 +4454,15 @@ public override async Task Outer_parameter_in_group_join_with_DefaultIfEmpty(boo await base.Outer_parameter_in_group_join_with_DefaultIfEmpty(async); AssertSql( - @"SELECT [g].[Nickname], [g].[SquadId], [t0].[Note], [t0].[Id] + @"SELECT [g].[Nickname], [g].[SquadId], [t0].[Note], [t0].[Id], [t0].[Nickname], [t0].[SquadId] FROM [Gears] AS [g] OUTER APPLY ( - SELECT [t].[Note], [t].[Id] + SELECT [t].[Note], [t].[Id], [g0].[Nickname], [g0].[SquadId] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g0] ON [g].[FullName] = [g0].[FullName] ) AS [t0] WHERE [g].[Discriminator] = N'Officer' -ORDER BY [g].[Nickname], [g].[SquadId], [t0].[Id]"); +ORDER BY [g].[Nickname], [g].[SquadId], [t0].[Id], [t0].[Nickname], [t0].[SquadId]"); } public override async Task Negated_bool_ternary_inside_anonymous_type_in_projection(bool async) @@ -5904,7 +5904,7 @@ public override async Task Project_collection_navigation_nested_with_take_compos await base.Project_collection_navigation_nested_with_take_composite_key(async); AssertSql( - @"SELECT [t].[Id], [t0].[Nickname], [t0].[SquadId], [t0].[AssignedCityName], [t0].[CityOfBirthName], [t0].[Discriminator], [t0].[FullName], [t0].[HasSoulPatch], [t0].[LeaderNickname], [t0].[LeaderSquadId], [t0].[Rank] + @"SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [t0].[Nickname], [t0].[SquadId], [t0].[AssignedCityName], [t0].[CityOfBirthName], [t0].[Discriminator], [t0].[FullName], [t0].[HasSoulPatch], [t0].[LeaderNickname], [t0].[LeaderSquadId], [t0].[Rank] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) OUTER APPLY ( @@ -5913,7 +5913,7 @@ FROM [Gears] AS [g0] WHERE ([g].[Nickname] IS NOT NULL AND [g].[SquadId] IS NOT NULL) AND (([g].[Nickname] = [g0].[LeaderNickname]) AND ([g].[SquadId] = [g0].[LeaderSquadId])) ) AS [t0] WHERE [g].[Discriminator] = N'Officer' -ORDER BY [t].[Id], [t0].[Nickname], [t0].[SquadId]"); +ORDER BY [t].[Id], [g].[Nickname], [g].[SquadId], [t0].[Nickname], [t0].[SquadId]"); } public override async Task Project_collection_navigation_nested_composite_key(bool async) @@ -5921,12 +5921,12 @@ public override async Task Project_collection_navigation_nested_composite_key(bo await base.Project_collection_navigation_nested_composite_key(async); AssertSql( - @"SELECT [t].[Id], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] + @"SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) LEFT JOIN [Gears] AS [g0] ON (([g].[Nickname] = [g0].[LeaderNickname]) OR ([g].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND ([g].[SquadId] = [g0].[LeaderSquadId]) WHERE [g].[Discriminator] = N'Officer' -ORDER BY [t].[Id], [g0].[Nickname], [g0].[SquadId]"); +ORDER BY [t].[Id], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Null_checks_in_correlated_predicate_are_correctly_translated(bool async) @@ -6095,14 +6095,14 @@ public override async Task Acessing_reference_navigation_collection_composition_ await base.Acessing_reference_navigation_collection_composition_generates_single_query(async); AssertSql( - @"SELECT [g].[Nickname], [g].[SquadId], [t].[Id], [t].[IsAutomatic], [t].[Name] + @"SELECT [g].[Nickname], [g].[SquadId], [t].[Id], [t].[IsAutomatic], [t].[Name], [t].[Id0] FROM [Gears] AS [g] LEFT JOIN ( - SELECT [w].[Id], [w].[IsAutomatic], [w0].[Name], [w].[OwnerFullName] + SELECT [w].[Id], [w].[IsAutomatic], [w0].[Name], [w0].[Id] AS [Id0], [w].[OwnerFullName] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ) AS [t] ON [g].[FullName] = [t].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id]"); +ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id], [t].[Id0]"); } public override async Task Reference_include_chain_loads_correctly_when_middle_is_null(bool async) @@ -6125,15 +6125,15 @@ public override async Task Accessing_property_of_optional_navigation_in_child_pr @"SELECT CASE WHEN [g].[Nickname] IS NOT NULL AND [g].[SquadId] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END, [t].[Id], [t0].[Nickname], [t0].[Id] +END, [t].[Id], [g].[Nickname], [g].[SquadId], [t0].[Nickname], [t0].[Id], [t0].[SquadId] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) LEFT JOIN ( - SELECT [g0].[Nickname], [w].[Id], [w].[OwnerFullName] + SELECT [g0].[Nickname], [w].[Id], [g0].[SquadId], [w].[OwnerFullName] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g0] ON [w].[OwnerFullName] = [g0].[FullName] ) AS [t0] ON [g].[FullName] = [t0].[OwnerFullName] -ORDER BY [t].[Note], [t].[Id], [t0].[Id]"); +ORDER BY [t].[Note], [t].[Id], [g].[Nickname], [g].[SquadId], [t0].[Id], [t0].[Nickname], [t0].[SquadId]"); } public override async Task Collection_navigation_ofType_filter_works(bool async) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceRelationshipsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceRelationshipsQuerySqlServerTest.cs index 7e8bed8c852..0e8f84848bb 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceRelationshipsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceRelationshipsQuerySqlServerTest.cs @@ -448,7 +448,7 @@ public override void Nested_include_with_inheritance_reference_collection1() FROM [BaseEntities] AS [b] LEFT JOIN [BaseReferencesOnBase] AS [b0] ON [b].[Id] = [b0].[BaseParentId] LEFT JOIN [NestedCollections] AS [n] ON [b0].[Id] = [n].[ParentReferenceId] -ORDER BY [b].[Id], [n].[Id]"); +ORDER BY [b].[Id], [b0].[Id], [n].[Id]"); } public override void Nested_include_with_inheritance_reference_collection3() @@ -461,7 +461,7 @@ FROM [BaseEntities] AS [b] LEFT JOIN [BaseReferencesOnBase] AS [b0] ON [b].[Id] = [b0].[BaseParentId] LEFT JOIN [NestedCollections] AS [n] ON [b0].[Id] = [n].[ParentReferenceId] WHERE [b].[Discriminator] = N'DerivedInheritanceRelationshipEntity' -ORDER BY [b].[Id], [n].[Id]"); +ORDER BY [b].[Id], [b0].[Id], [n].[Id]"); } public override void Nested_include_with_inheritance_reference_collection_reverse() @@ -487,7 +487,7 @@ LEFT JOIN ( FROM [BaseCollectionsOnBase] AS [b0] LEFT JOIN [NestedReferences] AS [n] ON [b0].[Id] = [n].[ParentCollectionId] ) AS [t] ON [b].[Id] = [t].[BaseParentId] -ORDER BY [b].[Id], [t].[Id]"); +ORDER BY [b].[Id], [t].[Id], [t].[Id0]"); } public override void Nested_include_with_inheritance_collection_reference_reverse() @@ -539,7 +539,7 @@ LEFT JOIN ( FROM [PrincipalEntities] AS [p] LEFT JOIN [ReferencedEntities] AS [r0] ON [p].[ReferenceId] = [r0].[Id] ) AS [t] ON [r].[Id] = [t].[ReferencedEntityId] -ORDER BY [r].[Id], [t].[Id]"); +ORDER BY [r].[Id], [t].[Id], [t].[Id0]"); } private void AssertSql(params string[] expected) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs index e672018b7c0..093e42aa074 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs @@ -143,7 +143,7 @@ public override void Include_reference_and_collection(bool useString) FROM [Orders] AS [o] LEFT JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID] LEFT JOIN [Order Details] AS [o0] ON [o].[OrderID] = [o0].[OrderID] -ORDER BY [o].[OrderID], [o0].[OrderID], [o0].[ProductID]"); +ORDER BY [o].[OrderID], [c].[CustomerID], [o0].[OrderID], [o0].[ProductID]"); } public override void Include_references_multi_level(bool useString) @@ -191,7 +191,7 @@ FROM [Order Details] AS [o] INNER JOIN [Orders] AS [o0] ON [o].[OrderID] = [o0].[OrderID] LEFT JOIN [Customers] AS [c] ON [o0].[CustomerID] = [c].[CustomerID] LEFT JOIN [Orders] AS [o1] ON [c].[CustomerID] = [o1].[CustomerID] -ORDER BY [o].[OrderID], [o].[ProductID], [o0].[OrderID], [o1].[OrderID]"); +ORDER BY [o].[OrderID], [o].[ProductID], [o0].[OrderID], [c].[CustomerID], [o1].[OrderID]"); } public override void Include_multi_level_reference_and_collection_predicate(bool useString) @@ -207,7 +207,7 @@ FROM [Orders] AS [o] WHERE [o].[OrderID] = 10248 ) AS [t] LEFT JOIN [Orders] AS [o0] ON [t].[CustomerID0] = [o0].[CustomerID] -ORDER BY [t].[OrderID], [o0].[OrderID]"); +ORDER BY [t].[OrderID], [t].[CustomerID0], [o0].[OrderID]"); } public override void Include_multi_level_collection_and_then_include_reference_predicate(bool useString) @@ -476,19 +476,85 @@ public override void Include_collection_when_projection(bool useString) FROM [Customers] AS [c]"); } - public override void Include_collection_on_join_clause_with_filter(bool useString) + public override void Include_collection_with_join_clause_with_filter(bool useString) { - base.Include_collection_on_join_clause_with_filter(useString); + base.Include_collection_with_join_clause_with_filter(useString); AssertSql( @"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [o].[OrderID], [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate] FROM [Customers] AS [c] INNER JOIN [Orders] AS [o] ON [c].[CustomerID] = [o].[CustomerID] LEFT JOIN [Orders] AS [o0] ON [c].[CustomerID] = [o0].[CustomerID] -WHERE [c].[CustomerID] = N'ALFKI' +WHERE [c].[CustomerID] LIKE N'F%' +ORDER BY [c].[CustomerID], [o].[OrderID], [o0].[OrderID]"); + } + + public override void Include_collection_with_left_join_clause_with_filter(bool useString) + { + base.Include_collection_with_left_join_clause_with_filter(useString); + + AssertSql( + @"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [o].[OrderID], [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate] +FROM [Customers] AS [c] +LEFT JOIN [Orders] AS [o] ON [c].[CustomerID] = [o].[CustomerID] +LEFT JOIN [Orders] AS [o0] ON [c].[CustomerID] = [o0].[CustomerID] +WHERE [c].[CustomerID] LIKE N'F%' ORDER BY [c].[CustomerID], [o].[OrderID], [o0].[OrderID]"); } + public override void Include_collection_with_cross_join_clause_with_filter(bool useString) + { + base.Include_collection_with_cross_join_clause_with_filter(useString); + + 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].[OrderID], [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate] +FROM [Customers] AS [c] +CROSS JOIN ( + SELECT TOP(5) [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] + FROM [Orders] AS [o] + ORDER BY [o].[OrderID] +) AS [t] +LEFT JOIN [Orders] AS [o0] ON [c].[CustomerID] = [o0].[CustomerID] +WHERE [c].[CustomerID] LIKE N'F%' +ORDER BY [c].[CustomerID], [t].[OrderID], [o0].[OrderID]"); + } + + public override void Include_collection_with_cross_apply_with_filter(bool useString) + { + base.Include_collection_with_cross_apply_with_filter(useString); + + 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].[OrderID], [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate] +FROM [Customers] AS [c] +CROSS APPLY ( + SELECT TOP(5) [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], [c].[CustomerID] AS [CustomerID0] + FROM [Orders] AS [o] + WHERE [c].[CustomerID] = [o].[CustomerID] + ORDER BY [c].[CustomerID] +) AS [t] +LEFT JOIN [Orders] AS [o0] ON [c].[CustomerID] = [o0].[CustomerID] +WHERE [c].[CustomerID] LIKE N'F%' +ORDER BY [c].[CustomerID], [t].[OrderID], [o0].[OrderID]"); + } + + public override void Include_collection_with_outer_apply_with_filter(bool useString) + { + base.Include_collection_with_outer_apply_with_filter(useString); + + 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].[OrderID], [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate] +FROM [Customers] AS [c] +OUTER APPLY ( + SELECT TOP(5) [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], [c].[CustomerID] AS [CustomerID0] + FROM [Orders] AS [o] + WHERE [c].[CustomerID] = [o].[CustomerID] + ORDER BY [c].[CustomerID] +) AS [t] +LEFT JOIN [Orders] AS [o0] ON [c].[CustomerID] = [o0].[CustomerID] +WHERE [c].[CustomerID] LIKE N'F%' +ORDER BY [c].[CustomerID], [t].[OrderID], [o0].[OrderID]"); + } + public override void Include_collection_on_additional_from_clause_with_filter(bool useString) { base.Include_collection_on_additional_from_clause_with_filter(useString); @@ -924,9 +990,9 @@ public override void Include_collection_with_multiple_conditional_order_by(bool AssertSql( @"@__p_0='5' -SELECT [t].[OrderID], [t].[CustomerID], [t].[EmployeeID], [t].[OrderDate], [o0].[OrderID], [o0].[ProductID], [o0].[Discount], [o0].[Quantity], [o0].[UnitPrice] +SELECT [t].[OrderID], [t].[CustomerID], [t].[EmployeeID], [t].[OrderDate], [t].[CustomerID0], [o0].[OrderID], [o0].[ProductID], [o0].[Discount], [o0].[Quantity], [o0].[UnitPrice] FROM ( - SELECT TOP(@__p_0) [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], CASE + SELECT TOP(@__p_0) [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], [c].[CustomerID] AS [CustomerID0], CASE WHEN [o].[OrderID] > 0 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [c], CASE @@ -944,7 +1010,7 @@ ELSE N'' END ) AS [t] LEFT JOIN [Order Details] AS [o0] ON [t].[OrderID] = [o0].[OrderID] -ORDER BY [t].[c], [t].[c0], [t].[OrderID], [o0].[OrderID], [o0].[ProductID]"); +ORDER BY [t].[c], [t].[c0], [t].[OrderID], [t].[CustomerID0], [o0].[OrderID], [o0].[ProductID]"); } public override void Then_include_collection_order_by_collection_column(bool useString) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqlServerTest.cs index 23e65a56f3a..ab35e005495 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqlServerTest.cs @@ -102,7 +102,7 @@ public override async Task KeylessEntity_with_defining_query_and_correlated_coll await base.KeylessEntity_with_defining_query_and_correlated_collection(async); AssertSql( - @"SELECT [o].[OrderID], [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate] + @"SELECT [o].[OrderID], [c].[CustomerID], [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate] FROM ( select * from ""Orders"" ) AS [o] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs index 3f3a9d4d387..07161c4f887 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs @@ -417,12 +417,12 @@ public override async Task Select_collection_navigation_multi_part(bool async) await base.Select_collection_navigation_multi_part(async); AssertSql( - @"SELECT [o].[OrderID], [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate] + @"SELECT [o].[OrderID], [c].[CustomerID], [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate] 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' -ORDER BY [o].[OrderID], [o0].[OrderID]"); +ORDER BY [o].[OrderID], [c].[CustomerID], [o0].[OrderID]"); } public override async Task Select_collection_navigation_multi_part2(bool async) @@ -430,13 +430,13 @@ public override async Task Select_collection_navigation_multi_part2(bool async) await base.Select_collection_navigation_multi_part2(async); AssertSql( - @"SELECT [o].[OrderID], [o].[ProductID], [o0].[OrderID], [o1].[OrderID], [o1].[CustomerID], [o1].[EmployeeID], [o1].[OrderDate] + @"SELECT [o].[OrderID], [o].[ProductID], [o0].[OrderID], [c].[CustomerID], [o1].[OrderID], [o1].[CustomerID], [o1].[EmployeeID], [o1].[OrderDate] FROM [Order Details] AS [o] INNER JOIN [Orders] AS [o0] ON [o].[OrderID] = [o0].[OrderID] LEFT JOIN [Customers] AS [c] ON [o0].[CustomerID] = [c].[CustomerID] LEFT JOIN [Orders] AS [o1] ON [c].[CustomerID] = [o1].[CustomerID] WHERE ([o0].[CustomerID] = N'ALFKI') OR ([o0].[CustomerID] = N'ANTON') -ORDER BY [o].[OrderID], [o].[ProductID], [o0].[OrderID], [o1].[OrderID]"); +ORDER BY [o].[OrderID], [o].[ProductID], [o0].[OrderID], [c].[CustomerID], [o1].[OrderID]"); } public override async Task Collection_select_nav_prop_any(bool async) @@ -678,7 +678,7 @@ FROM [Customers] AS [c] LEFT JOIN ( SELECT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region], [t].[OrderID], [t].[CustomerID0] FROM ( - SELECT [c0].[CustomerID], [c0].[Address], [c0].[City], [c0].[CompanyName], [c0].[ContactName], [c0].[ContactTitle], [c0].[Country], [c0].[Fax], [c0].[Phone], [c0].[PostalCode], [c0].[Region], [o].[OrderID], [o].[CustomerID] AS [CustomerID0], ROW_NUMBER() OVER(PARTITION BY [o].[CustomerID] ORDER BY [o].[OrderID]) AS [row] + SELECT [c0].[CustomerID], [c0].[Address], [c0].[City], [c0].[CompanyName], [c0].[ContactName], [c0].[ContactTitle], [c0].[Country], [c0].[Fax], [c0].[Phone], [c0].[PostalCode], [c0].[Region], [o].[OrderID], [o].[CustomerID] AS [CustomerID0], ROW_NUMBER() OVER(PARTITION BY [o].[CustomerID] ORDER BY [o].[OrderID], [c0].[CustomerID]) AS [row] FROM [Orders] AS [o] LEFT JOIN [Customers] AS [c0] ON [o].[CustomerID] = [c0].[CustomerID] WHERE [o].[OrderID] IN (10643, 10692, 10702, 10835, 10952, 11011) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryFiltersQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryFiltersQuerySqlServerTest.cs index 68318f5d6f4..6fde44ce88b 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryFiltersQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryFiltersQuerySqlServerTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Linq; @@ -115,10 +115,10 @@ public override void Include_query() AssertSql( @"@__ef_filter__TenantPrefix_0='B' (Size = 4000) -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [t0].[OrderID], [t0].[CustomerID], [t0].[EmployeeID], [t0].[OrderDate] +SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [t0].[OrderID], [t0].[CustomerID], [t0].[EmployeeID], [t0].[OrderDate], [t0].[CustomerID0] FROM [Customers] AS [c] LEFT JOIN ( - SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] + SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], [t].[CustomerID] AS [CustomerID0] FROM [Orders] AS [o] 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] @@ -128,7 +128,7 @@ FROM [Customers] AS [c0] WHERE [t].[CustomerID] IS NOT NULL AND [t].[CompanyName] IS NOT NULL ) AS [t0] ON [c].[CustomerID] = [t0].[CustomerID] WHERE (@__ef_filter__TenantPrefix_0 = N'') OR ([c].[CompanyName] IS NOT NULL AND (LEFT([c].[CompanyName], LEN(@__ef_filter__TenantPrefix_0)) = @__ef_filter__TenantPrefix_0)) -ORDER BY [c].[CustomerID], [t0].[OrderID]"); +ORDER BY [c].[CustomerID], [t0].[OrderID], [t0].[CustomerID0]"); } public override void Include_query_opt_out() @@ -193,7 +193,7 @@ public override void Navs_query() 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].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] + SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], [t].[CustomerID] AS [CustomerID0] FROM [Orders] AS [o] 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] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs index 6da3fb01a62..cc723da7f1a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; @@ -1177,11 +1177,11 @@ public override async Task Select_chained_entity_navigation_doesnt_materialize_i await base.Select_chained_entity_navigation_doesnt_materialize_intermittent_entities(async); AssertSql( - @"SELECT [o].[OrderID], [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate] + @"SELECT [o].[OrderID], [c].[CustomerID], [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate] FROM [Orders] AS [o] LEFT JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID] LEFT JOIN [Orders] AS [o0] ON [c].[CustomerID] = [o0].[CustomerID] -ORDER BY [o].[OrderID], [o0].[OrderID]"); +ORDER BY [o].[OrderID], [c].[CustomerID], [o0].[OrderID]"); } public override async Task Select_entity_compared_to_null(bool async) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs index 020c7c643ca..cbd824e5326 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs @@ -202,12 +202,12 @@ public override async Task Filter_owned_entity_chained_with_regular_entity_follo await base.Filter_owned_entity_chained_with_regular_entity_followed_by_projecting_owned_collection(async); AssertSql( - @"SELECT [o].[Id], [o0].[ClientId], [o0].[Id], [o0].[OrderDate] + @"SELECT [o].[Id], [p].[Id], [o0].[ClientId], [o0].[Id], [o0].[OrderDate] FROM [OwnedPerson] AS [o] LEFT JOIN [Planet] AS [p] ON [o].[PersonAddress_Country_PlanetId] = [p].[Id] LEFT JOIN [Order] AS [o0] ON [o].[Id] = [o0].[ClientId] WHERE ([p].[Id] <> 42) OR [p].[Id] IS NULL -ORDER BY [o].[Id], [o0].[ClientId], [o0].[Id]"); +ORDER BY [o].[Id], [p].[Id], [o0].[ClientId], [o0].[Id]"); } public override async Task Project_multiple_owned_navigations(bool async) @@ -219,7 +219,7 @@ public override async Task Project_multiple_owned_navigations(bool async) FROM [OwnedPerson] AS [o] LEFT JOIN [Planet] AS [p] ON [o].[PersonAddress_Country_PlanetId] = [p].[Id] LEFT JOIN [Order] AS [o0] ON [o].[Id] = [o0].[ClientId] -ORDER BY [o].[Id], [o0].[ClientId], [o0].[Id]"); +ORDER BY [o].[Id], [p].[Id], [o0].[ClientId], [o0].[Id]"); } public override async Task Project_multiple_owned_navigations_with_expansion_on_owned_collections(bool async) @@ -244,12 +244,12 @@ public override async Task Navigation_rewrite_on_owned_reference_followed_by_reg await base.Navigation_rewrite_on_owned_reference_followed_by_regular_entity_filter(async); AssertSql( - @"SELECT [o].[Id], [o].[Discriminator], [o].[Name], [o].[PersonAddress_AddressLine], [o].[PersonAddress_PlaceType], [o].[PersonAddress_ZipCode], [o].[PersonAddress_Country_Name], [o].[PersonAddress_Country_PlanetId], [o].[BranchAddress_BranchName], [o].[BranchAddress_PlaceType], [o].[BranchAddress_Country_Name], [o].[BranchAddress_Country_PlanetId], [o].[LeafBAddress_LeafBType], [o].[LeafBAddress_PlaceType], [o].[Id], [o].[LeafBAddress_Country_Name], [o].[LeafBAddress_Country_PlanetId], [o].[LeafAAddress_LeafType], [o].[LeafAAddress_PlaceType], [o].[LeafAAddress_Country_Name], [o].[LeafAAddress_Country_PlanetId], [o0].[ClientId], [o0].[Id], [o0].[OrderDate] + @"SELECT [o].[Id], [o].[Discriminator], [o].[Name], [o].[PersonAddress_AddressLine], [o].[PersonAddress_PlaceType], [o].[PersonAddress_ZipCode], [o].[PersonAddress_Country_Name], [o].[PersonAddress_Country_PlanetId], [o].[BranchAddress_BranchName], [o].[BranchAddress_PlaceType], [o].[BranchAddress_Country_Name], [o].[BranchAddress_Country_PlanetId], [o].[LeafBAddress_LeafBType], [o].[LeafBAddress_PlaceType], [o].[Id], [o].[LeafBAddress_Country_Name], [o].[LeafBAddress_Country_PlanetId], [o].[LeafAAddress_LeafType], [o].[LeafAAddress_PlaceType], [o].[LeafAAddress_Country_Name], [o].[LeafAAddress_Country_PlanetId], [p].[Id], [o0].[ClientId], [o0].[Id], [o0].[OrderDate] FROM [OwnedPerson] AS [o] LEFT JOIN [Planet] AS [p] ON [o].[PersonAddress_Country_PlanetId] = [p].[Id] LEFT JOIN [Order] AS [o0] ON [o].[Id] = [o0].[ClientId] WHERE ([p].[Id] <> 7) OR [p].[Id] IS NULL -ORDER BY [o].[Id], [o0].[ClientId], [o0].[Id]"); +ORDER BY [o].[Id], [p].[Id], [o0].[ClientId], [o0].[Id]"); } public override async Task Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_property(bool async) @@ -267,11 +267,11 @@ public override async Task Navigation_rewrite_on_owned_reference_followed_by_reg await base.Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_collection(async); AssertSql( - @"SELECT [o].[Id], [m].[Id], [m].[Diameter], [m].[PlanetId] + @"SELECT [o].[Id], [p].[Id], [m].[Id], [m].[Diameter], [m].[PlanetId] FROM [OwnedPerson] AS [o] LEFT JOIN [Planet] AS [p] ON [o].[PersonAddress_Country_PlanetId] = [p].[Id] LEFT JOIN [Moon] AS [m] ON [p].[Id] = [m].[PlanetId] -ORDER BY [o].[Id], [m].[Id]"); +ORDER BY [o].[Id], [p].[Id], [m].[Id]"); } public override async Task SelectMany_on_owned_reference_followed_by_regular_entity_and_collection(bool async) @@ -302,12 +302,12 @@ public override async Task Navigation_rewrite_on_owned_reference_followed_by_reg await base.Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_another_reference(async); AssertSql( - @"SELECT [s].[Id], [s].[Name], [o].[Id], [e].[Id], [e].[Name], [e].[StarId] + @"SELECT [s].[Id], [s].[Name], [o].[Id], [p].[Id], [e].[Id], [e].[Name], [e].[StarId] FROM [OwnedPerson] AS [o] LEFT JOIN [Planet] AS [p] ON [o].[PersonAddress_Country_PlanetId] = [p].[Id] LEFT JOIN [Star] AS [s] ON [p].[StarId] = [s].[Id] LEFT JOIN [Element] AS [e] ON [s].[Id] = [e].[StarId] -ORDER BY [o].[Id], [e].[Id]"); +ORDER BY [o].[Id], [p].[Id], [s].[Id], [e].[Id]"); } public override async Task Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_another_reference_and_scalar( @@ -329,13 +329,13 @@ await base.Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_ async); AssertSql( - @"SELECT [s].[Id], [s].[Name], [o].[Id], [e].[Id], [e].[Name], [e].[StarId] + @"SELECT [s].[Id], [s].[Name], [o].[Id], [p].[Id], [e].[Id], [e].[Name], [e].[StarId] FROM [OwnedPerson] AS [o] LEFT JOIN [Planet] AS [p] ON [o].[PersonAddress_Country_PlanetId] = [p].[Id] LEFT JOIN [Star] AS [s] ON [p].[StarId] = [s].[Id] LEFT JOIN [Element] AS [e] ON [s].[Id] = [e].[StarId] WHERE [s].[Name] = N'Sol' -ORDER BY [o].[Id], [e].[Id]"); +ORDER BY [o].[Id], [p].[Id], [s].[Id], [e].[Id]"); } public override async Task Query_with_OfType_eagerly_loads_correct_owned_navigations(bool async) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs index 8c17b75fc0e..76a80b0fb45 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs @@ -2747,9 +2747,9 @@ public virtual void Repro9735() AssertSql( @"@__p_0='2' -SELECT [t].[Id], [t].[AddressId], [t].[CustomerDetailsId], [t].[Name], [t].[Id0], [o].[Id], [o].[CustomerId], [o].[Name] +SELECT [t].[Id], [t].[AddressId], [t].[CustomerDetailsId], [t].[Name], [t].[Id0], [t].[Id1], [o].[Id], [o].[CustomerId], [o].[Name] FROM ( - SELECT TOP(@__p_0) [c].[Id], [c].[AddressId], [c].[CustomerDetailsId], [c].[Name], [a].[Id] AS [Id0], CASE + SELECT TOP(@__p_0) [c].[Id], [c].[AddressId], [c].[CustomerDetailsId], [c].[Name], [a].[Id] AS [Id0], [c0].[Id] AS [Id1], CASE WHEN [a].[Id] > 0 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [c], CASE @@ -2768,7 +2768,7 @@ ELSE N'' END ) AS [t] LEFT JOIN [Order9735] AS [o] ON [t].[Id] = [o].[CustomerId] -ORDER BY [t].[c], [t].[c0], [t].[Id], [t].[Id0], [o].[Id]"); +ORDER BY [t].[c], [t].[c0], [t].[Id], [t].[Id0], [t].[Id1], [o].[Id]"); } } @@ -5964,10 +5964,10 @@ public virtual async Task Async_correlated_projection_with_first() Assert.Equal(new[] { 1, 2 }, result.ThingIds); AssertSql( - @"SELECT [e].[Id], [t0].[ThingId], [t0].[Id] + @"SELECT [e].[Id], [t0].[ThingId], [t0].[Id], [t0].[Id0] FROM [Entities] AS [e] OUTER APPLY ( - SELECT [s].[ThingId], [t].[Id] + SELECT [s].[ThingId], [t].[Id], [s].[Id] AS [Id0] FROM [Things] AS [t] LEFT JOIN [Subthings] AS [s] ON [t].[Id] = [s].[ThingId] WHERE ( @@ -5981,7 +5981,7 @@ SELECT TOP(1) [v0].[Id] FROM [Values] AS [v0] WHERE [e].[Id] = [v0].[Entity11023Id]) IS NULL AND [t].[Value11023Id] IS NULL)) ) AS [t0] -ORDER BY [e].[Id], [t0].[Id]"); +ORDER BY [e].[Id], [t0].[Id], [t0].[Id0]"); } } @@ -6404,7 +6404,7 @@ FROM [DbTradeAsset] AS [d0] INNER JOIN [DbContract] AS [d1] ON [d0].[ContractId] = [d1].[Id] LEFT JOIN [DbSeason] AS [d2] ON [d1].[SeasonId] = [d2].[Id] ) AS [t1] ON [t0].[Id] = [t1].[DbTradeId] -ORDER BY [t0].[Id], [t1].[Id], [t1].[Id0]"); +ORDER BY [t0].[Id], [t1].[Id], [t1].[Id0], [t1].[Id1]"); } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindIncludeQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindIncludeQuerySqliteTest.cs index 5aaabd9a616..cc80bc3d6f9 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindIncludeQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindIncludeQuerySqliteTest.cs @@ -19,5 +19,14 @@ public override void Include_collection_order_by_non_key_with_take(bool useStrin { base.Include_collection_order_by_non_key_with_take(useString); } + + // Sqlite does not support Apply operations + public override void Include_collection_with_cross_apply_with_filter(bool useString) + { + } + + public override void Include_collection_with_outer_apply_with_filter(bool useString) + { + } } }