From 76161c7b0900697352ddd4a02603b37c0ad062fe Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Sun, 24 Dec 2023 13:41:03 +0100 Subject: [PATCH] Redo SQL tree pruning Closes #31083 Fixes #31407 --- ...electExpressionPruningExpressionVisitor.cs | 53 ---- .../Query/QuerySqlGenerator.cs | 61 ++-- ...RelationalQueryTranslationPostprocessor.cs | 15 +- .../Query/SqlExpressions/ExceptExpression.cs | 2 +- .../Query/SqlExpressions/ExistsExpression.cs | 8 +- .../Query/SqlExpressions/InExpression.cs | 8 +- .../SqlExpressions/InnerJoinExpression.cs | 9 - .../SqlExpressions/IntersectExpression.cs | 2 +- .../SqlExpressions/LeftJoinExpression.cs | 9 - .../PredicateJoinExpressionBase.cs | 9 + .../ScalarSubqueryExpression.cs | 9 +- .../SqlExpressions/SelectExpression.Helper.cs | 77 ----- .../Query/SqlExpressions/SelectExpression.cs | 162 ++++++---- .../Query/SqlExpressions/SetOperationBase.cs | 9 + .../Query/SqlExpressions/UnionExpression.cs | 2 +- src/EFCore.Relational/Query/SqlTreePruner.cs | 153 ++++++++++ .../Internal/SqlServerJsonPostprocessor.cs | 7 +- .../Internal/SqlServerQuerySqlGenerator.cs | 61 +++- .../NonSharedModelBulkUpdatesSqlServerTest.cs | 17 +- .../NorthwindBulkUpdatesSqlServerTest.cs | 54 ++-- ...tersInheritanceBulkUpdatesSqlServerTest.cs | 12 +- .../TPCInheritanceBulkUpdatesSqlServerTest.cs | 12 +- ...tersInheritanceBulkUpdatesSqlServerTest.cs | 10 - .../TPTInheritanceBulkUpdatesSqlServerTest.cs | 5 - .../AdHocManyToManyQuerySqlServerTest.cs | 2 +- .../AdHocMiscellaneousQuerySqlServerTest.cs | 5 +- .../AdHocQueryFiltersQuerySqlServerTest.cs | 12 +- ...CollectionsSharedTypeQuerySqlServerTest.cs | 4 +- .../ComplexNavigationsQuerySqlServerTest.cs | 10 +- ...NavigationsSharedTypeQuerySqlServerTest.cs | 162 +++++----- .../Query/Ef6GroupBySqlServerTest.cs | 2 +- .../Query/GearsOfWarQuerySqlServerTest.cs | 50 ++- .../Query/JsonQuerySqlServerTest.cs | 19 +- .../ManyToManyNoTrackingQuerySqlServerTest.cs | 2 +- .../Query/ManyToManyQuerySqlServerTest.cs | 2 +- ...dPrimitiveCollectionsQuerySqlServerTest.cs | 28 +- ...indAggregateOperatorsQuerySqlServerTest.cs | 10 +- .../NorthwindGroupByQuerySqlServerTest.cs | 24 +- .../Query/NorthwindJoinQuerySqlServerTest.cs | 2 +- ...orthwindMiscellaneousQuerySqlServerTest.cs | 78 ++--- .../NorthwindNavigationsQuerySqlServerTest.cs | 4 +- ...NorthwindQueryTaggingQuerySqlServerTest.cs | 2 +- .../NorthwindSelectQuerySqlServerTest.cs | 4 +- .../Query/OwnedQuerySqlServerTest.cs | 6 +- .../PrimitiveCollectionsQuerySqlServerTest.cs | 18 +- .../Query/TPCGearsOfWarQuerySqlServerTest.cs | 284 +++++++++--------- .../TPCInheritanceQuerySqlServerTestBase.cs | 6 +- ...CManyToManyNoTrackingQuerySqlServerTest.cs | 8 +- .../Query/TPCManyToManyQuerySqlServerTest.cs | 8 +- .../Query/TPTGearsOfWarQuerySqlServerTest.cs | 169 ++--------- .../Query/TPTInheritanceQuerySqlServerTest.cs | 7 +- ...TManyToManyNoTrackingQuerySqlServerTest.cs | 10 +- .../Query/TPTManyToManyQuerySqlServerTest.cs | 10 +- ...CollectionsSharedTypeQuerySqlServerTest.cs | 2 +- .../TemporalGearsOfWarQuerySqlServerTest.cs | 50 ++- .../TemporalManyToManyQuerySqlServerTest.cs | 2 +- .../Query/TemporalOwnedQuerySqlServerTest.cs | 6 +- .../Query/UdfDbFunctionSqlServerTests.cs | 2 +- .../NonSharedModelBulkUpdatesSqliteTest.cs | 2 + .../NorthwindBulkUpdatesSqliteTest.cs | 66 ++-- ...FiltersInheritanceBulkUpdatesSqliteTest.cs | 12 +- .../TPCInheritanceBulkUpdatesSqliteTest.cs | 12 +- ...FiltersInheritanceBulkUpdatesSqliteTest.cs | 18 +- .../TPTInheritanceBulkUpdatesSqliteTest.cs | 13 +- .../Query/GearsOfWarQuerySqliteTest.cs | 50 ++- .../Query/JsonQuerySqliteTest.cs | 16 +- .../NorthwindMiscellaneousQuerySqliteTest.cs | 8 +- .../PrimitiveCollectionsQuerySqliteTest.cs | 14 +- .../Query/TPCGearsOfWarQuerySqliteTest.cs | 4 +- .../Query/TPTGearsOfWarQuerySqliteTest.cs | 1 - 70 files changed, 965 insertions(+), 1027 deletions(-) delete mode 100644 src/EFCore.Relational/Query/Internal/SelectExpressionPruningExpressionVisitor.cs create mode 100644 src/EFCore.Relational/Query/SqlTreePruner.cs diff --git a/src/EFCore.Relational/Query/Internal/SelectExpressionPruningExpressionVisitor.cs b/src/EFCore.Relational/Query/Internal/SelectExpressionPruningExpressionVisitor.cs deleted file mode 100644 index 1757d3bdfc2..00000000000 --- a/src/EFCore.Relational/Query/Internal/SelectExpressionPruningExpressionVisitor.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics.CodeAnalysis; -using Microsoft.EntityFrameworkCore.Query.SqlExpressions; - -namespace Microsoft.EntityFrameworkCore.Query.Internal; - -/// -/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to -/// the same compatibility standards as public APIs. It may be changed or removed without notice in -/// any release. You should only use it directly in your code with extreme caution and knowing that -/// doing so can result in application failures when updating to a new Entity Framework Core release. -/// -public class SelectExpressionPruningExpressionVisitor : ExpressionVisitor -{ - /// - /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to - /// the same compatibility standards as public APIs. It may be changed or removed without notice in - /// any release. You should only use it directly in your code with extreme caution and knowing that - /// doing so can result in application failures when updating to a new Entity Framework Core release. - /// - [return: NotNullIfNotNull("expression")] - public override Expression? Visit(Expression? expression) - { - switch (expression) - { - case ShapedQueryExpression shapedQueryExpression: - return shapedQueryExpression.Update( - ((SelectExpression)shapedQueryExpression.QueryExpression).Prune(), - Visit(shapedQueryExpression.ShaperExpression)); - - case RelationalSplitCollectionShaperExpression relationalSplitCollectionShaperExpression: - return relationalSplitCollectionShaperExpression.Update( - relationalSplitCollectionShaperExpression.ParentIdentifier, - relationalSplitCollectionShaperExpression.ChildIdentifier, - relationalSplitCollectionShaperExpression.SelectExpression.Prune(), - Visit(relationalSplitCollectionShaperExpression.InnerShaper)); - - case DeleteExpression deleteExpression: - return deleteExpression.Update(deleteExpression.SelectExpression.Prune()); - - case UpdateExpression updateExpression: - return updateExpression.Update( - updateExpression.SelectExpression.Prune(), - updateExpression.ColumnValueSetters.Select(e => new ColumnValueSetter(e.Column, (SqlExpression)Visit(e.Value))) - .ToList()); - - default: - return base.Visit(expression); - } - } -} diff --git a/src/EFCore.Relational/Query/QuerySqlGenerator.cs b/src/EFCore.Relational/Query/QuerySqlGenerator.cs index 282ebc50ea0..ed574161e0e 100644 --- a/src/EFCore.Relational/Query/QuerySqlGenerator.cs +++ b/src/EFCore.Relational/Query/QuerySqlGenerator.cs @@ -182,9 +182,8 @@ private static bool IsNonComposedSetOperation(SelectExpression selectExpression) && selectExpression.Projection.Count == setOperation.Source1.Projection.Count && selectExpression.Projection.Select( (pe, index) => pe.Expression is ColumnExpression column - && string.Equals(column.TableAlias, setOperation.Alias, StringComparison.Ordinal) - && string.Equals( - column.Name, setOperation.Source1.Projection[index].Alias, StringComparison.Ordinal)) + && column.TableAlias == setOperation.Alias + && column.Name == setOperation.Source1.Projection[index].Alias) .All(e => e); /// @@ -237,26 +236,8 @@ protected override Expression VisitSelect(SelectExpression selectExpression) } GenerateTop(selectExpression); - - if (selectExpression.Projection.Any()) - { - GenerateList(selectExpression.Projection, e => Visit(e)); - } - else - { - GenerateEmptyProjection(selectExpression); - } - - if (selectExpression.Tables.Any()) - { - _relationalCommandBuilder.AppendLine().Append("FROM "); - - GenerateList(selectExpression.Tables, e => Visit(e), sql => sql.AppendLine()); - } - else - { - GeneratePseudoFromClause(); - } + GenerateProjection(selectExpression); + GenerateTables(selectExpression); if (selectExpression.Predicate != null) { @@ -1060,6 +1041,40 @@ protected virtual void GenerateTop(SelectExpression selectExpression) { } + /// + /// Generates the projection in the relational command + /// + /// A select expression to use. + protected virtual void GenerateProjection(SelectExpression selectExpression) + { + if (selectExpression.Projection.Any()) + { + GenerateList(selectExpression.Projection, e => Visit(e)); + } + else + { + GenerateEmptyProjection(selectExpression); + } + } + + /// + /// Generates the tables in the relational command + /// + /// A select expression to use. + protected virtual void GenerateTables(SelectExpression selectExpression) + { + if (selectExpression.Tables.Any()) + { + _relationalCommandBuilder.AppendLine().Append("FROM "); + + GenerateList(selectExpression.Tables, e => Visit(e), sql => sql.AppendLine()); + } + else + { + GeneratePseudoFromClause(); + } + } + /// /// Generates an ORDER BY clause in the relational command /// diff --git a/src/EFCore.Relational/Query/RelationalQueryTranslationPostprocessor.cs b/src/EFCore.Relational/Query/RelationalQueryTranslationPostprocessor.cs index c166dbcc10f..0e825e87dea 100644 --- a/src/EFCore.Relational/Query/RelationalQueryTranslationPostprocessor.cs +++ b/src/EFCore.Relational/Query/RelationalQueryTranslationPostprocessor.cs @@ -10,6 +10,7 @@ namespace Microsoft.EntityFrameworkCore.Query; /// public class RelationalQueryTranslationPostprocessor : QueryTranslationPostprocessor { + private readonly SqlTreePruner _pruner = new(); private readonly bool _useRelationalNulls; /// @@ -39,7 +40,7 @@ public override Expression Process(Expression query) query = base.Process(query); query = new SelectExpressionProjectionApplyingExpressionVisitor( ((RelationalQueryCompilationContext)QueryCompilationContext).QuerySplittingBehavior).Visit(query); - query = new SelectExpressionPruningExpressionVisitor().Visit(query); + query = Prune(query); #if DEBUG // Verifies that all SelectExpression are marked as immutable after this point. @@ -56,6 +57,13 @@ public override Expression Process(Expression query) return query; } + /// + /// Prunes unnecessarily objects from the SQL tree, e.g. tables which aren't referenced by any column. + /// Can be overridden by providers for provider-specific pruning. + /// + protected virtual Expression Prune(Expression query) + => _pruner.Prune(query); + #if DEBUG private sealed class SelectExpressionMutableVerifyingExpressionVisitor : ExpressionVisitor { @@ -64,7 +72,7 @@ private sealed class SelectExpressionMutableVerifyingExpressionVisitor : Express { switch (expression) { - case SelectExpression selectExpression when selectExpression.IsMutable(): + case SelectExpression { IsMutable: true } selectExpression: throw new InvalidDataException(selectExpression.Print()); case ShapedQueryExpression shapedQueryExpression: @@ -123,7 +131,8 @@ public Expression EntryPoint(Expression expression) if (expression is SelectExpression selectExpression) { - foreach (var alias in selectExpression.RemovedAliases()) + Check.DebugAssert(selectExpression.RemovedAliases is not null, "RemovedAliases not set"); + foreach (var alias in selectExpression.RemovedAliases) { _usedAliases.Add(alias); } diff --git a/src/EFCore.Relational/Query/SqlExpressions/ExceptExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/ExceptExpression.cs index dd834b5fd11..f5e25ef5f2d 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/ExceptExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/ExceptExpression.cs @@ -56,7 +56,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// The property of the result. /// The property of the result. /// This expression if no children changed, or an expression with the updated children. - public virtual ExceptExpression Update(SelectExpression source1, SelectExpression source2) + public override ExceptExpression Update(SelectExpression source1, SelectExpression source2) => source1 != Source1 || source2 != Source2 ? new ExceptExpression(Alias, source1, source2, IsDistinct, GetAnnotations()) : this; diff --git a/src/EFCore.Relational/Query/SqlExpressions/ExistsExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/ExistsExpression.cs index aac6952f23f..c3108c0aa8c 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/ExistsExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/ExistsExpression.cs @@ -24,12 +24,8 @@ public ExistsExpression( RelationalTypeMapping? typeMapping) : base(typeof(bool), typeMapping) { -#if DEBUG - if (subquery.IsMutable()) - { - throw new InvalidOperationException(); - } -#endif + Check.DebugAssert(!subquery.IsMutable, "Mutable subquery provided to ExistsExpression"); + Subquery = subquery; } diff --git a/src/EFCore.Relational/Query/SqlExpressions/InExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/InExpression.cs index e4d79a63784..d8b4198bbc0 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/InExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/InExpression.cs @@ -66,12 +66,8 @@ private InExpression( RelationalTypeMapping? typeMapping) : base(typeof(bool), typeMapping) { -#if DEBUG - if (subquery?.IsMutable() == true) - { - throw new InvalidOperationException(); - } -#endif + Check.DebugAssert(subquery?.IsMutable != true, "Mutable subquery provided to ExistsExpression"); + Item = item; Subquery = subquery; Values = values; diff --git a/src/EFCore.Relational/Query/SqlExpressions/InnerJoinExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/InnerJoinExpression.cs index f3287684c79..e43e83fc52e 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/InnerJoinExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/InnerJoinExpression.cs @@ -32,15 +32,6 @@ private InnerJoinExpression( { } - /// - protected override Expression VisitChildren(ExpressionVisitor visitor) - { - var table = (TableExpressionBase)visitor.Visit(Table); - var joinPredicate = (SqlExpression)visitor.Visit(JoinPredicate); - - return Update(table, joinPredicate); - } - /// /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will /// return this expression. diff --git a/src/EFCore.Relational/Query/SqlExpressions/IntersectExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/IntersectExpression.cs index b836e278043..3d883e05fbd 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/IntersectExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/IntersectExpression.cs @@ -56,7 +56,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// The property of the result. /// The property of the result. /// This expression if no children changed, or an expression with the updated children. - public virtual IntersectExpression Update(SelectExpression source1, SelectExpression source2) + public override IntersectExpression Update(SelectExpression source1, SelectExpression source2) => source1 != Source1 || source2 != Source2 ? new IntersectExpression(Alias, source1, source2, IsDistinct, GetAnnotations()) : this; diff --git a/src/EFCore.Relational/Query/SqlExpressions/LeftJoinExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/LeftJoinExpression.cs index b0eceb1e0a2..f35ae5b2eb7 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/LeftJoinExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/LeftJoinExpression.cs @@ -32,15 +32,6 @@ private LeftJoinExpression( { } - /// - protected override Expression VisitChildren(ExpressionVisitor visitor) - { - var table = (TableExpressionBase)visitor.Visit(Table); - var joinPredicate = (SqlExpression)visitor.Visit(JoinPredicate); - - return Update(table, joinPredicate); - } - /// /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will /// return this expression. diff --git a/src/EFCore.Relational/Query/SqlExpressions/PredicateJoinExpressionBase.cs b/src/EFCore.Relational/Query/SqlExpressions/PredicateJoinExpressionBase.cs index a1df3330052..1c8b1283bcc 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/PredicateJoinExpressionBase.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/PredicateJoinExpressionBase.cs @@ -44,6 +44,15 @@ protected PredicateJoinExpressionBase( /// public virtual SqlExpression JoinPredicate { get; } + /// + protected override Expression VisitChildren(ExpressionVisitor visitor) + { + var table = (TableExpressionBase)visitor.Visit(Table); + var joinPredicate = (SqlExpression)visitor.Visit(JoinPredicate); + + return Update(table, joinPredicate); + } + /// /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will /// return this expression. diff --git a/src/EFCore.Relational/Query/SqlExpressions/ScalarSubqueryExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/ScalarSubqueryExpression.cs index 50a87586d2d..334d8a682e8 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/ScalarSubqueryExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/ScalarSubqueryExpression.cs @@ -32,18 +32,13 @@ private ScalarSubqueryExpression(SelectExpression subquery, RelationalTypeMappin private static SelectExpression Verify(SelectExpression selectExpression) { + Check.DebugAssert(!selectExpression.IsMutable, "Mutable subquery provided to ExistsExpression"); + if (selectExpression.Projection.Count != 1) { throw new InvalidOperationException(CoreStrings.TranslationFailed(selectExpression.Print())); } -#if DEBUG - if (selectExpression.IsMutable()) - { - throw new InvalidOperationException(); - } -#endif - return selectExpression; } diff --git a/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.Helper.cs b/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.Helper.cs index e1d43c09754..5a0c5a25474 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.Helper.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.Helper.cs @@ -270,83 +270,6 @@ public EnclosingTermFindingVisitor(HashSet correlatedTerms) } } - private sealed class ColumnExpressionFindingExpressionVisitor : ExpressionVisitor - { - private Dictionary?>? _columnReferenced; - private Dictionary?>? _columnsUsedInJoinCondition; - - public Dictionary?> FindColumns(SelectExpression selectExpression) - { - _columnReferenced = new Dictionary?>(); - _columnsUsedInJoinCondition = new Dictionary?>(); - - foreach (var table in selectExpression.Tables) - { - var tableAlias = table is JoinExpressionBase joinExpressionBase - ? joinExpressionBase.Table.Alias! - : table.Alias!; - _columnReferenced[tableAlias] = null; - } - - Visit(selectExpression); - - foreach (var keyValuePair in _columnsUsedInJoinCondition) - { - var tableAlias = keyValuePair.Key; - if (_columnReferenced[tableAlias] != null - && _columnsUsedInJoinCondition[tableAlias] != null) - { - _columnReferenced[tableAlias]!.UnionWith(_columnsUsedInJoinCondition[tableAlias]!); - } - } - - return _columnReferenced; - } - - [return: NotNullIfNotNull("expression")] - public override Expression? Visit(Expression? expression) - { - switch (expression) - { - case ColumnExpression columnExpression: - var tableAlias = columnExpression.TableAlias; - if (_columnReferenced!.ContainsKey(tableAlias)) - { - _columnReferenced[tableAlias] ??= new HashSet(); - - _columnReferenced[tableAlias]!.Add(columnExpression.Name); - } - - // Always skip the table of ColumnExpression since it will traverse into deeper subquery - return columnExpression; - - case PredicateJoinExpressionBase predicateJoinExpressionBase: - var predicateJoinTableAlias = predicateJoinExpressionBase.Table.Alias!; - // Visiting the join predicate will add some columns for join table. - // But if all the referenced columns are in join predicate only then we can remove the join table. - // So if there are no referenced columns yet means there is still potential to remove this table, - // In such case we moved the columns encountered in join predicate to other dictionary and later merge - // if there are more references to the join table outside of join predicate. - // We should also remove references to the outer if this column gets removed then that subquery can also remove projections - // But currently we only remove table for TPT & entity splitting scenario - // in which there are all table expressions which connects via joins. - var joinOnSameLevel = _columnReferenced!.ContainsKey(predicateJoinTableAlias); - var noReferences = !joinOnSameLevel || _columnReferenced[predicateJoinTableAlias] == null; - base.Visit(predicateJoinExpressionBase); - if (noReferences && joinOnSameLevel) - { - _columnsUsedInJoinCondition![predicateJoinTableAlias] = _columnReferenced[predicateJoinTableAlias]; - _columnReferenced[predicateJoinTableAlias] = null; - } - - return predicateJoinExpressionBase; - - default: - return base.Visit(expression); - } - } - } - private sealed class TableReferenceUpdatingExpressionVisitor : ExpressionVisitor { private readonly SelectExpression _oldSelect; diff --git a/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs index f02eb427101..e5f4334892f 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs @@ -57,7 +57,7 @@ public sealed partial class SelectExpression : TableExpressionBase private List<(ColumnExpression Column, ValueComparer Comparer)>? _preGroupByIdentifier; #if DEBUG - private List? _removedAliases; + internal List? RemovedAliases { get; set; } #endif private SelectExpression( @@ -4347,89 +4347,127 @@ public SelectExpression Clone() /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [EntityFrameworkInternal] - public SelectExpression Prune() + public SelectExpression PruneToplevel( + ExpressionVisitor pruningVisitor, + IReadOnlyDictionary> referencedColumnMap, + List removedAliases) { - var selectExpression = (SelectExpression)new TpcTableExpressionRemovingExpressionVisitor(_usedAliases).Visit(this); -#if DEBUG - selectExpression._removedAliases = new List(); - selectExpression = selectExpression.Prune(referencedColumns: null, selectExpression._removedAliases); -#else - selectExpression = selectExpression.Prune(referencedColumns: null); -#endif - return selectExpression; + // TODO: This doesn't belong in pruning, take a deeper look at how we manage TPC etc. + var select = (SelectExpression)new TpcTableExpressionRemovingExpressionVisitor(_usedAliases).Visit(this); + select.Prune(pruningVisitor, isTopLevel: true, pruneProjection: false, referencedColumnMap, removedAliases); + return select; } -#if DEBUG - private SelectExpression Prune(IReadOnlyCollection? referencedColumns, List removedAliases) -#else - private SelectExpression Prune(IReadOnlyCollection? referencedColumns) -#endif + /// + /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to + /// the same compatibility standards as public APIs. It may be changed or removed without notice in + /// any release. You should only use it directly in your code with extreme caution and knowing that + /// doing so can result in application failures when updating to a new Entity Framework Core release. + /// + [EntityFrameworkInternal] + public void Prune( + ExpressionVisitor pruningVisitor, + bool isTopLevel, + bool pruneProjection, + IReadOnlyDictionary> referencedColumnMap, + List removedAliases) { - if (referencedColumns != null - && !IsDistinct) + Check.DebugAssert(!IsMutable, "Mutable SelectExpression found when pruning"); + + // Prune the projection; any projected alias that isn't referenced on us from the outside can be removed. We avoid doing that when: + // 1. The caller requests we don't (select within a set operation where the other is distinct - projection must be preserved as-is) + // 2. The select has distinct (removing a projection changes which rows get projected out) + // 3. We're at the top-level select. + var prunedProjection = _projection; + if (pruneProjection && !IsDistinct && !isTopLevel) { - for (var i = _projection.Count - 1; i >= 0; i--) + if (referencedColumnMap.TryGetValue(this, out var referencedProjectionAliases)) { - if (!referencedColumns.Contains(_projection[i].Alias)) + for (var i = _projection.Count - 1; i >= 0; i--) { - _projection.RemoveAt(i); + if (!referencedProjectionAliases.Contains(_projection[i].Alias)) + { + _projection.RemoveAt(i); + } } } + else + { + _projection.Clear(); + } + } + + // First visit all the non-table clauses of the SelectExpression - this will populate referencedColumnMap with all columns + // referenced on all tables. + if (pruningVisitor.VisitAndConvert(prunedProjection) is var newProjection && newProjection != _projection) + { + _projection.Clear(); + _projection.AddRange(newProjection); } + Predicate = (SqlExpression?)pruningVisitor.Visit(Predicate); + + if (pruningVisitor.VisitAndConvert(_groupBy) is var newGroupBy && newGroupBy != _groupBy) + { + _groupBy.Clear(); + _groupBy.AddRange(newGroupBy); + } + + Having = (SqlExpression?)pruningVisitor.Visit(Having); + + if (pruningVisitor.VisitAndConvert(_orderings) is var newOrderings && newOrderings != _orderings) + { + _orderings.Clear(); + _orderings.AddRange(newOrderings); + } + + Offset = (SqlExpression?)pruningVisitor.Visit(Offset); + Limit = (SqlExpression?)pruningVisitor.Visit(Limit); + + // TODO: This should happen earlier, not as part of pruning. _identifier.Clear(); _childIdentifiers.Clear(); - var columnExpressionFindingExpressionVisitor = new ColumnExpressionFindingExpressionVisitor(); - var columnsMap = columnExpressionFindingExpressionVisitor.FindColumns(this); - var removedTableCount = 0; - // Start at 1 because we don't drop main table. - // Dropping main table is more complex because other tables need to unwrap joins to be main - for (var i = 0; i < _tables.Count; i++) + + foreach (var kvp in _tpcDiscriminatorValues) + { + var newColumn = pruningVisitor.Visit(kvp.Value.Item1); + Check.DebugAssert(newColumn == kvp.Value.Item1, "TPC discriminator column replaced during pruning"); + } + + // We've visited the entire select expression except for the table, and now have referencedColumnMap fully populated with column + // references to all its tables. + // Go over the tables, removing any which aren't referenced anywhere (and are prunable). + // We do this in backwards order, so that later joins referencing earlier tables in the predicate don't cause the earlier tables + // to be preserved. + for (var i = _tables.Count - 1; i >= 0; i--) { var table = _tables[i]; - var tableAlias = GetAliasFromTableExpressionBase(table); - if (columnsMap[tableAlias] == null - // InnerJoin is only valid for removable join table which are from entity splitting + var wrappedTable = table.UnwrapJoin(); + + if (!referencedColumnMap.ContainsKey(wrappedTable) + // Note that we only prune joins; pruning the main is more complex because other tables need to unwrap joins to be main. + // TODO: why not CrossApplyExpression/CrossJoin (any join basically)? && table is LeftJoinExpression or OuterApplyExpression or InnerJoinExpression - && _removableJoinTables?.Contains(i + removedTableCount) == true) + // Only prune InnerJoin if it's in the removable list; since inner joins filter out rows, it may be needed even if it's not + // referenced from anywhere in the query. + && _removableJoinTables.Contains(i)) { _tables.RemoveAt(i); _tableReferences.RemoveAt(i); - removedTableCount++; - i--; #if DEBUG - removedAliases.Add(tableAlias); + removedAliases.Add(wrappedTable.Alias!); #endif continue; } - if (UnwrapJoinExpression(table) is SelectExpression innerSelectExpression) + // The table wasn't pruned - visit it. This may add references to a previous table, causing it to be preserved (e.g. if it's + // referenced from the join predicate), or just prune something inside (e.g. a subquery table). + var newTable = (TableExpressionBase)pruningVisitor.Visit(table); + if (newTable != table) { -#if DEBUG - innerSelectExpression.Prune(columnsMap[tableAlias], removedAliases); -#else - innerSelectExpression.Prune(columnsMap[tableAlias]); -#endif - } - else if (table is SetOperationBase { IsDistinct: false } setOperation) - { - if (setOperation.Source1.IsDistinct - || setOperation.Source2.IsDistinct) - { - continue; - } - -#if DEBUG - setOperation.Source1.Prune(columnsMap[tableAlias], removedAliases); - setOperation.Source2.Prune(columnsMap[tableAlias], removedAliases); -#else - setOperation.Source1.Prune(columnsMap[tableAlias]); - setOperation.Source2.Prune(columnsMap[tableAlias]); -#endif + _tables[i] = newTable; } } - - return this; } private Dictionary ConvertProjectionMappingToClientProjections( @@ -4913,6 +4951,9 @@ public SelectExpression Update( projectionMapping[projectionMember] = expression; } + // TODO: This assumes that no tables were added or removed (e.g. pruning). Update should be usable for that case. + // TODO: This always creates a new expression. It should check if anything changed instead (#31276), allowing us to remove "changed" + // tracking from calling code. var newTableReferences = _tableReferences.ToList(); var newSelectExpression = new SelectExpression( Alias, projections.ToList(), tables.ToList(), newTableReferences, groupBy.ToList(), orderings.ToList(), GetAnnotations()) @@ -5156,11 +5197,6 @@ public override int GetHashCode() // Since equality above is reference equality, hash code can also be based on reference. => RuntimeHelpers.GetHashCode(this); -#if DEBUG - internal bool IsMutable() + internal bool IsMutable => _mutable; - - internal IReadOnlyList RemovedAliases() - => _removedAliases!; -#endif } diff --git a/src/EFCore.Relational/Query/SqlExpressions/SetOperationBase.cs b/src/EFCore.Relational/Query/SqlExpressions/SetOperationBase.cs index 370519f245b..aa324cf1c97 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/SetOperationBase.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/SetOperationBase.cs @@ -78,6 +78,15 @@ public override string? Alias /// public virtual SelectExpression Source2 { get; } + /// + /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will + /// return this expression. + /// + /// The property of the result. + /// The property of the result. + /// This expression if no children changed, or an expression with the updated children. + public abstract SetOperationBase Update(SelectExpression source1, SelectExpression source2); + /// public override bool Equals(object? obj) => obj != null diff --git a/src/EFCore.Relational/Query/SqlExpressions/UnionExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/UnionExpression.cs index f72196243f2..eb4c4515e5e 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/UnionExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/UnionExpression.cs @@ -56,7 +56,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// The property of the result. /// The property of the result. /// This expression if no children changed, or an expression with the updated children. - public virtual UnionExpression Update(SelectExpression source1, SelectExpression source2) + public override UnionExpression Update(SelectExpression source1, SelectExpression source2) => source1 != Source1 || source2 != Source2 ? new UnionExpression(Alias, source1, source2, IsDistinct, GetAnnotations()) : this; diff --git a/src/EFCore.Relational/Query/SqlTreePruner.cs b/src/EFCore.Relational/Query/SqlTreePruner.cs new file mode 100644 index 00000000000..3fa83cb18b1 --- /dev/null +++ b/src/EFCore.Relational/Query/SqlTreePruner.cs @@ -0,0 +1,153 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.EntityFrameworkCore.Query.SqlExpressions; + +namespace Microsoft.EntityFrameworkCore.Query; + +/// +/// +/// A visitor that processes a SQL tree and prunes out parts which aren't needed. +/// +/// +/// This type is typically used by database providers (and other extensions). It is generally +/// not used in application code. +/// +/// +public class SqlTreePruner : ExpressionVisitor +{ + private readonly Dictionary> _referencedColumnMap = new(ReferenceEqualityComparer.Instance); + + /// + /// Maps tables to the list of column aliases found referenced on them. + /// + protected IReadOnlyDictionary> ReferencedColumnMap => _referencedColumnMap; + + // Used for extra verification for DEBUG only + private List _removedAliases = null!; + + /// + /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to + /// the same compatibility standards as public APIs. It may be changed or removed without notice in + /// any release. You should only use it directly in your code with extreme caution and knowing that + /// doing so can result in application failures when updating to a new Entity Framework Core release. + /// + public Expression Prune(Expression expression) + { + _referencedColumnMap.Clear(); + + return Visit(expression); + } + + /// + /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to + /// the same compatibility standards as public APIs. It may be changed or removed without notice in + /// any release. You should only use it directly in your code with extreme caution and knowing that + /// doing so can result in application failures when updating to a new Entity Framework Core release. + /// + protected override Expression VisitExtension(Expression node) + { + switch (node) + { + case ShapedQueryExpression shapedQueryExpression: + return shapedQueryExpression.Update( + PruneTopLevelSelect((SelectExpression)shapedQueryExpression.QueryExpression), + Visit(shapedQueryExpression.ShaperExpression)); + + case RelationalSplitCollectionShaperExpression relationalSplitCollectionShaperExpression: + return relationalSplitCollectionShaperExpression.Update( + relationalSplitCollectionShaperExpression.ParentIdentifier, + relationalSplitCollectionShaperExpression.ChildIdentifier, + PruneTopLevelSelect(relationalSplitCollectionShaperExpression.SelectExpression), + Visit(relationalSplitCollectionShaperExpression.InnerShaper)); + + case DeleteExpression deleteExpression: + return deleteExpression.Update(PruneTopLevelSelect(deleteExpression.SelectExpression)); + + case UpdateExpression updateExpression: + // Note that we must visit the setters before we visit the select, since the setters can reference tables inside it. + var visitedSetters = updateExpression.ColumnValueSetters + .Select(e => e with { Value = (SqlExpression)Visit(e.Value) }) + .ToList(); + return updateExpression.Update( + PruneTopLevelSelect(updateExpression.SelectExpression), + visitedSetters); + + // The following remaining cases deal with recursive visitation (i.e. non-top-level things) + + // For any column we encounter, register it in the referenced column map, which records the aliases referenced on each table. + case ColumnExpression column: + RegisterTable(column.Table.UnwrapJoin()); + + void RegisterTable(TableExpressionBase table) + { + _referencedColumnMap.GetOrAddNew(table).Add(column.Name); + + // If the table is a set operation, we need to recurse and register the contained tables as well. + // This is because when we visit a select inside a set operation, we need to be able to know who's referencing our + // projection from the outside (in order to prune unreferenced projections). + if (table is SetOperationBase setOperation) + { + RegisterTable(setOperation.Source1); + RegisterTable(setOperation.Source2); + } + } + + return column; + + // Note that this only handles nested selects, and *not* the top-level select - that was already handled above in the first + // cases. + case SelectExpression select: + select.Prune(this, isTopLevel: false, pruneProjection: true, ReferencedColumnMap, _removedAliases); + return select; + + // PredicateJoinExpressionBase.VisitChildren visits the table before the predicate, but we must visit the predicate first + // since it can contain columns referencing the table's projection (which we shouldn't prune). + case PredicateJoinExpressionBase join: + var joinPredicate = (SqlExpression)Visit(join.JoinPredicate); + var table = (TableExpressionBase)Visit(join.Table); + return join.Update(table, joinPredicate); + + // Never prune the projection of a scalar subquery. Note that there are never columns referencing scalar subqueries, since + // they're not tables. + case ScalarSubqueryExpression scalarSubquery: + scalarSubquery.Subquery.Prune(this, isTopLevel: false, pruneProjection: false, ReferencedColumnMap, _removedAliases); + return scalarSubquery; + + // Same for subqueries inside InExpression + case InExpression { Subquery: SelectExpression subquery } inExpression: + var item = (SqlExpression)Visit(inExpression.Item); + subquery.Prune(this, isTopLevel: false, pruneProjection: false, ReferencedColumnMap, _removedAliases); + return inExpression.Update(item, subquery); + + // If the set operation is distinct (union/intersect/except, but not concat), we cannot prune the projection since that would + // affect which rows come out. + // Also, even if the set operation is non-distinct but one side is distinct, we avoid pruning the projection since that could + // make the two sides have different and incompatible projections (see #30273). + // Note that we still visit to prune within the set operation, and to make sure the referenced column map gets updated. + case SetOperationBase { Source1: var source1, Source2: var source2 } setOperation + when setOperation.IsDistinct || source1.IsDistinct || source2.IsDistinct: + { + source1.Prune(this, isTopLevel: false, pruneProjection: false, ReferencedColumnMap, _removedAliases); + source2.Prune(this, isTopLevel: false, pruneProjection: false, ReferencedColumnMap, _removedAliases); + return setOperation; + } + + default: + return base.VisitExtension(node); + } + } + + private SelectExpression PruneTopLevelSelect(SelectExpression select) + { +#if DEBUG + _removedAliases = new(); +#endif + select = select.PruneToplevel(this, ReferencedColumnMap, _removedAliases); +#if DEBUG + select.RemovedAliases = _removedAliases; +#endif + + return select; + } +} diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerJsonPostprocessor.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerJsonPostprocessor.cs index 4baa71272c9..1af2e93282d 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerJsonPostprocessor.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerJsonPostprocessor.cs @@ -167,12 +167,7 @@ public virtual Expression Process(Expression expression) case ColumnExpression columnExpression: { - var table = columnExpression.Table; - if (table is JoinExpressionBase join) - { - table = join.Table; - } - + var table = columnExpression.Table.UnwrapJoin(); return table is SqlServerOpenJsonExpression openJsonTable && _columnsToRewrite.TryGetValue((openJsonTable, columnExpression.Name), out var columnRewriteInfo) ? RewriteOpenJsonColumn(columnExpression, columnRewriteInfo.SelectExpression, columnRewriteInfo.ColumnInfo) diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs index 11faf10b307..d47772968a6 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs @@ -21,6 +21,8 @@ public class SqlServerQuerySqlGenerator : QuerySqlGenerator private readonly ISqlGenerationHelper _sqlGenerationHelper; private readonly int _sqlServerCompatibilityLevel; + private bool _withinTable; + /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in @@ -97,13 +99,15 @@ protected override Expression VisitDelete(DeleteExpression deleteExpression) /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - protected override void GenerateEmptyProjection(SelectExpression selectExpression) + protected override Expression VisitSelect(SelectExpression selectExpression) { - base.GenerateEmptyProjection(selectExpression); - if (selectExpression.Alias != null) - { - Sql.Append(" AS empty"); - } + // SQL Server always requires column names to be specified in table subqueries, as opposed to e.g. scalar subqueries (this isn't + // a requirement in databases). So we must use visitor state to track whether we're (directly) within a table subquery, and + // generate "1 AS empty" instead of just "1". + var parentWithinTable = _withinTable; + base.VisitSelect(selectExpression); + _withinTable = parentWithinTable; + return selectExpression; } /// @@ -227,6 +231,9 @@ protected override void GenerateValues(ValuesExpression valuesExpression) /// protected override void GenerateTop(SelectExpression selectExpression) { + var parentWithinTable = _withinTable; + _withinTable = false; + if (selectExpression is { Limit: not null, Offset: null }) { Sql.Append("TOP("); @@ -235,6 +242,48 @@ protected override void GenerateTop(SelectExpression selectExpression) Sql.Append(") "); } + + _withinTable = parentWithinTable; + } + + /// + /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to + /// the same compatibility standards as public APIs. It may be changed or removed without notice in + /// any release. You should only use it directly in your code with extreme caution and knowing that + /// doing so can result in application failures when updating to a new Entity Framework Core release. + /// + protected override void GenerateProjection(SelectExpression selectExpression) + { + // SQL Server always requires column names to be specified in table subqueries, as opposed to e.g. scalar subqueries (this isn't + // a requirement in databases). So we must use visitor state to track whether we're (directly) within a table subquery, and + // generate "1 AS empty" instead of just "1". + if (selectExpression.Projection.Count == 0) + { + Sql.Append(_withinTable ? "1 AS empty" : "1"); + } + else + { + var parentWithinTable = _withinTable; + _withinTable = false; + GenerateList(selectExpression.Projection, e => Visit(e)); + _withinTable = parentWithinTable; + } + } + + /// + /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to + /// the same compatibility standards as public APIs. It may be changed or removed without notice in + /// any release. You should only use it directly in your code with extreme caution and knowing that + /// doing so can result in application failures when updating to a new Entity Framework Core release. + /// + protected override void GenerateTables(SelectExpression selectExpression) + { + // SQL Server always requires column names to be specified in table subqueries, as opposed to e.g. scalar subqueries (this isn't + // a requirement in databases). So we must use visitor state to track whether we're (directly) within a table subquery, and + // generate "1 AS empty" instead of just "1". + _withinTable = true; + base.GenerateTables(selectExpression); + _withinTable = false; } /// diff --git a/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesSqlServerTest.cs index ecf29e29302..112109b057c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesSqlServerTest.cs @@ -90,10 +90,19 @@ FROM [Blogs] AS [b] """); } - // #31407 - public override Task Update_non_main_table_in_entity_with_entity_splitting(bool async) - => Assert.ThrowsAnyAsync( - () => base.Update_non_main_table_in_entity_with_entity_splitting(async)); + public override async Task Update_non_main_table_in_entity_with_entity_splitting(bool async) + { + await base.Update_non_main_table_in_entity_with_entity_splitting(async); + + AssertSql( + """ +UPDATE [b0] +SET [b0].[Rating] = CAST(LEN([b0].[Title]) AS int), + [b0].[Title] = CONVERT(varchar(11), [b0].[Rating]) +FROM [Blogs] AS [b] +INNER JOIN [BlogsPart1] AS [b0] ON [b].[Id] = [b0].[Id] +"""); + } public override async Task Delete_entity_with_auto_include(bool async) { diff --git a/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqlServerTest.cs index 2987d957b01..0063c50edb3 100644 --- a/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqlServerTest.cs @@ -90,7 +90,7 @@ FROM [Order Details] AS [o] WHERE EXISTS ( SELECT 1 FROM ( - SELECT [o0].[OrderID], [o0].[ProductID], [o0].[Discount], [o0].[Quantity], [o0].[UnitPrice] + SELECT [o0].[OrderID], [o0].[ProductID] FROM [Order Details] AS [o0] WHERE [o0].[OrderID] < 10300 ORDER BY [o0].[OrderID] @@ -113,7 +113,7 @@ FROM [Order Details] AS [o] WHERE EXISTS ( SELECT 1 FROM ( - SELECT TOP(@__p_0) [o0].[OrderID], [o0].[ProductID], [o0].[Discount], [o0].[Quantity], [o0].[UnitPrice] + SELECT TOP(@__p_0) [o0].[OrderID], [o0].[ProductID] FROM [Order Details] AS [o0] WHERE [o0].[OrderID] < 10300 ORDER BY [o0].[OrderID] @@ -135,7 +135,7 @@ FROM [Order Details] AS [o] WHERE EXISTS ( SELECT 1 FROM ( - SELECT [o0].[OrderID], [o0].[ProductID], [o0].[Discount], [o0].[Quantity], [o0].[UnitPrice] + SELECT [o0].[OrderID], [o0].[ProductID] FROM [Order Details] AS [o0] WHERE [o0].[OrderID] < 10300 ORDER BY [o0].[OrderID] @@ -158,7 +158,7 @@ FROM [Order Details] AS [o] WHERE EXISTS ( SELECT 1 FROM ( - SELECT [o0].[OrderID], [o0].[ProductID], [o0].[Discount], [o0].[Quantity], [o0].[UnitPrice] + SELECT [o0].[OrderID], [o0].[ProductID] FROM [Order Details] AS [o0] WHERE [o0].[OrderID] < 10300 ORDER BY (SELECT 1) @@ -195,7 +195,7 @@ FROM [Order Details] AS [o] WHERE EXISTS ( SELECT 1 FROM ( - SELECT [o0].[OrderID], [o0].[ProductID], [o0].[Discount], [o0].[Quantity], [o0].[UnitPrice] + SELECT [o0].[OrderID], [o0].[ProductID] FROM [Order Details] AS [o0] WHERE [o0].[OrderID] < 10300 ORDER BY (SELECT 1) @@ -274,9 +274,9 @@ FROM [Order Details] AS [o] WHERE EXISTS ( SELECT 1 FROM ( - SELECT [t].[OrderID], [t].[ProductID], [t].[Discount], [t].[Quantity], [t].[UnitPrice] + SELECT [t].[OrderID], [t].[ProductID] FROM ( - SELECT [o0].[OrderID], [o0].[ProductID], [o0].[Discount], [o0].[Quantity], [o0].[UnitPrice] + SELECT [o0].[OrderID], [o0].[ProductID] FROM [Order Details] AS [o0] WHERE [o0].[OrderID] < 10300 ORDER BY (SELECT 1) @@ -326,7 +326,7 @@ WHERE EXISTS ( SELECT 1 FROM [Orders] AS [o0] INNER JOIN ( - SELECT [o1].[OrderID], [o1].[ProductID], [o1].[Discount], [o1].[Quantity], [o1].[UnitPrice] + SELECT [o1].[OrderID], [o1].[ProductID] FROM [Order Details] AS [o1] WHERE [o1].[ProductID] > 0 ) AS [t] ON [o0].[OrderID] = [t].[OrderID] @@ -395,11 +395,11 @@ FROM [Order Details] AS [o] WHERE EXISTS ( SELECT 1 FROM ( - SELECT [o0].[OrderID], [o0].[ProductID], [o0].[Discount], [o0].[Quantity], [o0].[UnitPrice] + SELECT [o0].[OrderID], [o0].[ProductID] FROM [Order Details] AS [o0] WHERE [o0].[OrderID] < 10250 UNION ALL - SELECT [o1].[OrderID], [o1].[ProductID], [o1].[Discount], [o1].[Quantity], [o1].[UnitPrice] + SELECT [o1].[OrderID], [o1].[ProductID] FROM [Order Details] AS [o1] WHERE [o1].[OrderID] > 11250 ) AS [t] @@ -519,7 +519,7 @@ public override async Task Delete_with_join(bool async) DELETE FROM [o] FROM [Order Details] AS [o] INNER JOIN ( - SELECT [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate] + SELECT [o0].[OrderID] FROM [Orders] AS [o0] WHERE [o0].[OrderID] < 10300 ORDER BY [o0].[OrderID] @@ -540,7 +540,7 @@ public override async Task Delete_with_left_join(bool async) DELETE FROM [o] FROM [Order Details] AS [o] LEFT JOIN ( - SELECT [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate] + SELECT [o0].[OrderID] FROM [Orders] AS [o0] WHERE [o0].[OrderID] < 10300 ORDER BY [o0].[OrderID] @@ -741,7 +741,7 @@ UPDATE [c] SET [c].[ContactName] = N'Updated' FROM [Customers] AS [c] INNER JOIN ( - SELECT [c0].[CustomerID], [c0].[Address], [c0].[City], [c0].[CompanyName], [c0].[ContactName], [c0].[ContactTitle], [c0].[Country], [c0].[Fax], [c0].[Phone], [c0].[PostalCode], [c0].[Region] + SELECT [c0].[CustomerID] FROM [Customers] AS [c0] WHERE [c0].[CustomerID] LIKE N'F%' ORDER BY (SELECT 1) @@ -778,7 +778,7 @@ UPDATE [c] SET [c].[ContactName] = N'Updated' FROM [Customers] AS [c] INNER JOIN ( - SELECT [c0].[CustomerID], [c0].[Address], [c0].[City], [c0].[CompanyName], [c0].[ContactName], [c0].[ContactTitle], [c0].[Country], [c0].[Fax], [c0].[Phone], [c0].[PostalCode], [c0].[Region] + SELECT [c0].[CustomerID] FROM [Customers] AS [c0] WHERE [c0].[CustomerID] LIKE N'F%' ORDER BY (SELECT 1) @@ -797,7 +797,7 @@ UPDATE [c] SET [c].[ContactName] = N'Updated' FROM [Customers] AS [c] INNER JOIN ( - SELECT [c0].[CustomerID], [c0].[Address], [c0].[City], [c0].[CompanyName], [c0].[ContactName], [c0].[ContactTitle], [c0].[Country], [c0].[Fax], [c0].[Phone], [c0].[PostalCode], [c0].[Region] + SELECT [c0].[CustomerID] FROM [Customers] AS [c0] WHERE [c0].[CustomerID] LIKE N'F%' ) AS [t] ON [c].[CustomerID] = [t].[CustomerID] @@ -816,7 +816,7 @@ UPDATE [c] SET [c].[ContactName] = N'Updated' FROM [Customers] AS [c] INNER JOIN ( - SELECT [c0].[CustomerID], [c0].[Address], [c0].[City], [c0].[CompanyName], [c0].[ContactName], [c0].[ContactTitle], [c0].[Country], [c0].[Fax], [c0].[Phone], [c0].[PostalCode], [c0].[Region] + SELECT [c0].[CustomerID] FROM [Customers] AS [c0] WHERE [c0].[CustomerID] LIKE N'F%' ORDER BY [c0].[City] @@ -837,7 +837,7 @@ UPDATE [c] SET [c].[ContactName] = N'Updated' FROM [Customers] AS [c] INNER JOIN ( - SELECT TOP(@__p_0) [c0].[CustomerID], [c0].[Address], [c0].[City], [c0].[CompanyName], [c0].[ContactName], [c0].[ContactTitle], [c0].[Country], [c0].[Fax], [c0].[Phone], [c0].[PostalCode], [c0].[Region] + SELECT TOP(@__p_0) [c0].[CustomerID] FROM [Customers] AS [c0] WHERE [c0].[CustomerID] LIKE N'F%' ORDER BY [c0].[City] @@ -858,7 +858,7 @@ UPDATE [c] SET [c].[ContactName] = N'Updated' FROM [Customers] AS [c] INNER JOIN ( - SELECT [c0].[CustomerID], [c0].[Address], [c0].[City], [c0].[CompanyName], [c0].[ContactName], [c0].[ContactTitle], [c0].[Country], [c0].[Fax], [c0].[Phone], [c0].[PostalCode], [c0].[Region] + SELECT [c0].[CustomerID] FROM [Customers] AS [c0] WHERE [c0].[CustomerID] LIKE N'F%' ORDER BY [c0].[City] @@ -880,9 +880,9 @@ UPDATE [c] SET [c].[ContactName] = N'Updated' FROM [Customers] AS [c] INNER JOIN ( - SELECT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region] + SELECT [t].[CustomerID] FROM ( - SELECT [c0].[CustomerID], [c0].[Address], [c0].[City], [c0].[CompanyName], [c0].[ContactName], [c0].[ContactTitle], [c0].[Country], [c0].[Fax], [c0].[Phone], [c0].[PostalCode], [c0].[Region] + SELECT [c0].[CustomerID], [c0].[City] FROM [Customers] AS [c0] WHERE [c0].[CustomerID] LIKE N'F%' ORDER BY [c0].[City] @@ -1169,11 +1169,11 @@ UPDATE [c] SET [c].[ContactName] = N'Updated' FROM [Customers] AS [c] INNER JOIN ( - SELECT [c0].[CustomerID], [c0].[Address], [c0].[City], [c0].[CompanyName], [c0].[ContactName], [c0].[ContactTitle], [c0].[Country], [c0].[Fax], [c0].[Phone], [c0].[PostalCode], [c0].[Region] + SELECT [c0].[CustomerID] FROM [Customers] AS [c0] WHERE [c0].[CustomerID] LIKE N'F%' UNION ALL - SELECT [c1].[CustomerID], [c1].[Address], [c1].[City], [c1].[CompanyName], [c1].[ContactName], [c1].[ContactTitle], [c1].[Country], [c1].[Fax], [c1].[Phone], [c1].[PostalCode], [c1].[Region] + SELECT [c1].[CustomerID] FROM [Customers] AS [c1] WHERE [c1].[CustomerID] LIKE N'A%' ) AS [t] ON [c].[CustomerID] = [t].[CustomerID] @@ -1232,7 +1232,7 @@ UPDATE [c] SET [c].[ContactName] = N'Updated' FROM [Customers] AS [c] INNER JOIN ( - SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] + SELECT [o].[CustomerID] FROM [Orders] AS [o] WHERE [o].[OrderID] < 10300 ) AS [t] ON [c].[CustomerID] = [t].[CustomerID] @@ -1250,7 +1250,7 @@ UPDATE [c] SET [c].[ContactName] = N'Updated' FROM [Customers] AS [c] LEFT JOIN ( - SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] + SELECT [o].[CustomerID] FROM [Orders] AS [o] WHERE [o].[OrderID] < 10300 ) AS [t] ON [c].[CustomerID] = [t].[CustomerID] @@ -1327,7 +1327,7 @@ FROM [Customers] AS [c0] WHERE [c0].[City] LIKE N'S%' ) AS [t] LEFT JOIN ( - SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] + SELECT [o].[CustomerID] FROM [Orders] AS [o] WHERE [o].[OrderID] < 10300 ) AS [t0] ON [c].[CustomerID] = [t0].[CustomerID] @@ -1398,10 +1398,10 @@ UPDATE [o] SET [o].[OrderDate] = NULL FROM [Orders] AS [o] INNER JOIN ( - SELECT [t].[OrderID], [t].[CustomerID], [t].[EmployeeID], [t].[OrderDate], [c].[CustomerID] AS [CustomerID0] + SELECT [t].[OrderID] FROM [Customers] AS [c] INNER JOIN ( - SELECT [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate] + SELECT [o0].[OrderID], [o0].[CustomerID] FROM [Orders] AS [o0] WHERE DATEPART(year, [o0].[OrderDate]) = 1997 ) AS [t] ON [c].[CustomerID] = [t].[CustomerID] diff --git a/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesSqlServerTest.cs index 95d6eff9797..0dca1b790a4 100644 --- a/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesSqlServerTest.cs @@ -47,10 +47,10 @@ FROM [Countries] AS [c] WHERE ( SELECT COUNT(*) FROM ( - SELECT [e].[Id], [e].[CountryId], [e].[Name], [e].[Species], [e].[EagleId], [e].[IsFlightless], [e].[Group], NULL AS [FoundOn], N'Eagle' AS [Discriminator] + SELECT [e].[CountryId] FROM [Eagle] AS [e] UNION ALL - SELECT [k].[Id], [k].[CountryId], [k].[Name], [k].[Species], [k].[EagleId], [k].[IsFlightless], NULL AS [Group], [k].[FoundOn], N'Kiwi' AS [Discriminator] + SELECT [k].[CountryId] FROM [Kiwi] AS [k] ) AS [t] WHERE [t].[CountryId] = 1 AND [c].[Id] = [t].[CountryId] AND [t].[CountryId] > 0) > 0 @@ -68,7 +68,7 @@ FROM [Countries] AS [c] WHERE ( SELECT COUNT(*) FROM ( - SELECT [k].[Id], [k].[CountryId], [k].[Name], [k].[Species], [k].[EagleId], [k].[IsFlightless], NULL AS [Group], [k].[FoundOn], N'Kiwi' AS [Discriminator] + SELECT [k].[CountryId] FROM [Kiwi] AS [k] ) AS [t] WHERE [t].[CountryId] = 1 AND [c].[Id] = [t].[CountryId] AND [t].[CountryId] > 0) > 0 @@ -169,10 +169,10 @@ FROM [Countries] AS [c] WHERE ( SELECT COUNT(*) FROM ( - SELECT [e].[Id], [e].[CountryId], [e].[Name], [e].[Species], [e].[EagleId], [e].[IsFlightless], [e].[Group], NULL AS [FoundOn], N'Eagle' AS [Discriminator] + SELECT [e].[CountryId] FROM [Eagle] AS [e] UNION ALL - SELECT [k].[Id], [k].[CountryId], [k].[Name], [k].[Species], [k].[EagleId], [k].[IsFlightless], NULL AS [Group], [k].[FoundOn], N'Kiwi' AS [Discriminator] + SELECT [k].[CountryId] FROM [Kiwi] AS [k] ) AS [t] WHERE [t].[CountryId] = 1 AND [c].[Id] = [t].[CountryId] AND [t].[CountryId] > 0) > 0 @@ -205,7 +205,7 @@ FROM [Countries] AS [c] WHERE ( SELECT COUNT(*) FROM ( - SELECT [k].[Id], [k].[CountryId], [k].[Name], [k].[Species], [k].[EagleId], [k].[IsFlightless], NULL AS [Group], [k].[FoundOn], N'Kiwi' AS [Discriminator] + SELECT [k].[CountryId] FROM [Kiwi] AS [k] ) AS [t] WHERE [t].[CountryId] = 1 AND [c].[Id] = [t].[CountryId] AND [t].[CountryId] > 0) > 0 diff --git a/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesSqlServerTest.cs index e4e40e53391..31502a450c4 100644 --- a/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesSqlServerTest.cs @@ -46,10 +46,10 @@ FROM [Countries] AS [c] WHERE ( SELECT COUNT(*) FROM ( - SELECT [e].[Id], [e].[CountryId], [e].[Name], [e].[Species], [e].[EagleId], [e].[IsFlightless], [e].[Group], NULL AS [FoundOn], N'Eagle' AS [Discriminator] + SELECT [e].[CountryId] FROM [Eagle] AS [e] UNION ALL - SELECT [k].[Id], [k].[CountryId], [k].[Name], [k].[Species], [k].[EagleId], [k].[IsFlightless], NULL AS [Group], [k].[FoundOn], N'Kiwi' AS [Discriminator] + SELECT [k].[CountryId] FROM [Kiwi] AS [k] ) AS [t] WHERE [c].[Id] = [t].[CountryId] AND [t].[CountryId] > 0) > 0 @@ -67,7 +67,7 @@ FROM [Countries] AS [c] WHERE ( SELECT COUNT(*) FROM ( - SELECT [k].[Id], [k].[CountryId], [k].[Name], [k].[Species], [k].[EagleId], [k].[IsFlightless], NULL AS [Group], [k].[FoundOn], N'Kiwi' AS [Discriminator] + SELECT [k].[CountryId] FROM [Kiwi] AS [k] ) AS [t] WHERE [c].[Id] = [t].[CountryId] AND [t].[CountryId] > 0) > 0 @@ -166,10 +166,10 @@ FROM [Countries] AS [c] WHERE ( SELECT COUNT(*) FROM ( - SELECT [e].[Id], [e].[CountryId], [e].[Name], [e].[Species], [e].[EagleId], [e].[IsFlightless], [e].[Group], NULL AS [FoundOn], N'Eagle' AS [Discriminator] + SELECT [e].[CountryId] FROM [Eagle] AS [e] UNION ALL - SELECT [k].[Id], [k].[CountryId], [k].[Name], [k].[Species], [k].[EagleId], [k].[IsFlightless], NULL AS [Group], [k].[FoundOn], N'Kiwi' AS [Discriminator] + SELECT [k].[CountryId] FROM [Kiwi] AS [k] ) AS [t] WHERE [c].[Id] = [t].[CountryId] AND [t].[CountryId] > 0) > 0 @@ -201,7 +201,7 @@ FROM [Countries] AS [c] WHERE ( SELECT COUNT(*) FROM ( - SELECT [k].[Id], [k].[CountryId], [k].[Name], [k].[Species], [k].[EagleId], [k].[IsFlightless], NULL AS [Group], [k].[FoundOn], N'Kiwi' AS [Discriminator] + SELECT [k].[CountryId] FROM [Kiwi] AS [k] ) AS [t] WHERE [c].[Id] = [t].[CountryId] AND [t].[CountryId] > 0) > 0 diff --git a/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesSqlServerTest.cs index 0b4714359b4..b0792c7cd4f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesSqlServerTest.cs @@ -42,9 +42,6 @@ FROM [Countries] AS [c] WHERE ( SELECT COUNT(*) FROM [Animals] AS [a] - LEFT JOIN [Birds] AS [b] ON [a].[Id] = [b].[Id] - LEFT JOIN [Eagle] AS [e] ON [a].[Id] = [e].[Id] - LEFT JOIN [Kiwi] AS [k] ON [a].[Id] = [k].[Id] WHERE [a].[CountryId] = 1 AND [c].[Id] = [a].[CountryId] AND [a].[CountryId] > 0) > 0 """); } @@ -60,8 +57,6 @@ FROM [Countries] AS [c] WHERE ( SELECT COUNT(*) FROM [Animals] AS [a] - LEFT JOIN [Birds] AS [b] ON [a].[Id] = [b].[Id] - LEFT JOIN [Eagle] AS [e] ON [a].[Id] = [e].[Id] LEFT JOIN [Kiwi] AS [k] ON [a].[Id] = [k].[Id] WHERE [a].[CountryId] = 1 AND [c].[Id] = [a].[CountryId] AND [k].[Id] IS NOT NULL AND [a].[CountryId] > 0) > 0 """); @@ -185,9 +180,6 @@ FROM [Countries] AS [c] WHERE ( SELECT COUNT(*) FROM [Animals] AS [a] - LEFT JOIN [Birds] AS [b] ON [a].[Id] = [b].[Id] - LEFT JOIN [Eagle] AS [e] ON [a].[Id] = [e].[Id] - LEFT JOIN [Kiwi] AS [k] ON [a].[Id] = [k].[Id] WHERE [a].[CountryId] = 1 AND [c].[Id] = [a].[CountryId] AND [a].[CountryId] > 0) > 0 """); } @@ -204,8 +196,6 @@ FROM [Countries] AS [c] WHERE ( SELECT COUNT(*) FROM [Animals] AS [a] - LEFT JOIN [Birds] AS [b] ON [a].[Id] = [b].[Id] - LEFT JOIN [Eagle] AS [e] ON [a].[Id] = [e].[Id] LEFT JOIN [Kiwi] AS [k] ON [a].[Id] = [k].[Id] WHERE [a].[CountryId] = 1 AND [c].[Id] = [a].[CountryId] AND [k].[Id] IS NOT NULL AND [a].[CountryId] > 0) > 0 """); diff --git a/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesSqlServerTest.cs index 2383e68cb73..97fddd65d8f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesSqlServerTest.cs @@ -159,9 +159,6 @@ FROM [Countries] AS [c] WHERE ( SELECT COUNT(*) FROM [Animals] AS [a] - LEFT JOIN [Birds] AS [b] ON [a].[Id] = [b].[Id] - LEFT JOIN [Eagle] AS [e] ON [a].[Id] = [e].[Id] - LEFT JOIN [Kiwi] AS [k] ON [a].[Id] = [k].[Id] WHERE [c].[Id] = [a].[CountryId] AND [a].[CountryId] > 0) > 0 """); } @@ -178,8 +175,6 @@ FROM [Countries] AS [c] WHERE ( SELECT COUNT(*) FROM [Animals] AS [a] - LEFT JOIN [Birds] AS [b] ON [a].[Id] = [b].[Id] - LEFT JOIN [Eagle] AS [e] ON [a].[Id] = [e].[Id] LEFT JOIN [Kiwi] AS [k] ON [a].[Id] = [k].[Id] WHERE [c].[Id] = [a].[CountryId] AND [k].[Id] IS NOT NULL AND [a].[CountryId] > 0) > 0 """); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocManyToManyQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocManyToManyQuerySqlServerTest.cs index 15312351ea6..2b776288518 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocManyToManyQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocManyToManyQuerySqlServerTest.cs @@ -21,7 +21,7 @@ FROM [Users] AS [u] CROSS JOIN ( SELECT [t].[Id] FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e] LEFT JOIN ( SELECT [o].[Id] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocMiscellaneousQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocMiscellaneousQuerySqlServerTest.cs index eabd336268f..95b8d5220d3 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocMiscellaneousQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocMiscellaneousQuerySqlServerTest.cs @@ -2271,10 +2271,7 @@ public override async Task GroupBy_aggregate_on_right_side_of_join(bool async) SELECT [o].[Id], [o].[CancellationDate], [o].[OrderId], [o].[ShippingDate] FROM [OrderItems] AS [o] INNER JOIN ( - SELECT [o0].[OrderId] AS [Key], MAX(CASE - WHEN [o0].[ShippingDate] IS NULL AND [o0].[CancellationDate] IS NULL THEN [o0].[OrderId] - ELSE [o0].[OrderId] - 10000000 - END) AS [IsPending] + SELECT [o0].[OrderId] AS [Key] FROM [OrderItems] AS [o0] WHERE [o0].[OrderId] = @__orderId_0 GROUP BY [o0].[OrderId] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocQueryFiltersQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocQueryFiltersQuerySqlServerTest.cs index 9e662295c21..c1706859d76 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocQueryFiltersQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocQueryFiltersQuerySqlServerTest.cs @@ -303,7 +303,7 @@ SELECT COUNT(*) FROM ( SELECT DISTINCT [c].[Value1] FROM ( - SELECT [p0].[Id], [p0].[Child1Id], [p0].[Child2Id], [p0].[ChildFilter1Id], [p0].[ChildFilter2Id], 1 AS [Key] + SELECT [p0].[Child1Id], 1 AS [Key] FROM [Parents] AS [p0] ) AS [t1] LEFT JOIN [Child1] AS [c] ON [t1].[Child1Id] = [c].[Id] @@ -313,7 +313,7 @@ SELECT COUNT(*) FROM ( SELECT DISTINCT [c0].[Value2] FROM ( - SELECT [p1].[Id], [p1].[Child1Id], [p1].[Child2Id], [p1].[ChildFilter1Id], [p1].[ChildFilter2Id], 1 AS [Key] + SELECT [p1].[Child2Id], 1 AS [Key] FROM [Parents] AS [p1] ) AS [t3] LEFT JOIN [Child2] AS [c0] ON [t3].[Child2Id] = [c0].[Id] @@ -338,11 +338,11 @@ SELECT COUNT(*) FROM ( SELECT DISTINCT [t2].[Value1] FROM ( - SELECT [p0].[Id], [p0].[Child1Id], [p0].[Child2Id], [p0].[ChildFilter1Id], [p0].[ChildFilter2Id], 1 AS [Key] + SELECT [p0].[ChildFilter1Id], 1 AS [Key] FROM [Parents] AS [p0] ) AS [t0] LEFT JOIN ( - SELECT [c].[Id], [c].[Filter1], [c].[Value1] + SELECT [c].[Id], [c].[Value1] FROM [ChildFilter1] AS [c] WHERE [c].[Filter1] = N'Filter1' ) AS [t2] ON [t0].[ChildFilter1Id] = [t2].[Id] @@ -352,11 +352,11 @@ SELECT COUNT(*) FROM ( SELECT DISTINCT [t5].[Value2] FROM ( - SELECT [p1].[Id], [p1].[Child1Id], [p1].[Child2Id], [p1].[ChildFilter1Id], [p1].[ChildFilter2Id], 1 AS [Key] + SELECT [p1].[ChildFilter2Id], 1 AS [Key] FROM [Parents] AS [p1] ) AS [t4] LEFT JOIN ( - SELECT [c0].[Id], [c0].[Filter2], [c0].[Value2] + SELECT [c0].[Id], [c0].[Value2] FROM [ChildFilter2] AS [c0] WHERE [c0].[Filter2] = N'Filter2' ) AS [t5] ON [t4].[ChildFilter2Id] = [t5].[Id] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs index 9eb962097c0..5a378336dca 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs @@ -2814,7 +2814,7 @@ WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] SELECT COUNT(*) FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Level3_Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id] + SELECT [l1].[Level3_Name], [l1].[OneToOne_Optional_PK_Inverse3Id] FROM [Level1] AS [l1] WHERE [l1].[Level2_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse3Id] IS NOT NULL ) AS [t] ON CASE @@ -3628,7 +3628,7 @@ WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] SELECT COUNT(*) FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Level3_Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id] + SELECT [l1].[Level3_Name], [l1].[OneToOne_Optional_PK_Inverse3Id] FROM [Level1] AS [l1] WHERE [l1].[Level2_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse3Id] IS NOT NULL ) AS [t] ON CASE diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs index 4f6ed7a4983..0be826f0044 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs @@ -2358,7 +2358,7 @@ FROM [LevelOne] AS [l] WHERE ( SELECT COUNT(*) FROM ( - SELECT TOP(10) [l0].[Id], [l1].[Id] AS [Id0] + SELECT TOP(10) 1 AS empty FROM [LevelOne] AS [l0] LEFT JOIN [LevelTwo] AS [l1] ON [l0].[Id] = [l1].[Level1_Optional_Id] WHERE ( @@ -2433,7 +2433,7 @@ public override async Task GroupJoin_with_subquery_on_inner(bool async) SELECT [l].[Id] FROM [LevelOne] AS [l] OUTER APPLY ( - SELECT TOP(10) [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] + SELECT TOP(10) 1 AS empty FROM [LevelTwo] AS [l0] WHERE [l].[Id] = [l0].[Level1_Optional_Id] AND [l0].[Id] > 0 ORDER BY [l0].[Id] @@ -2450,7 +2450,7 @@ public override async Task GroupJoin_with_subquery_on_inner_and_no_DefaultIfEmpt SELECT [l].[Id] FROM [LevelOne] AS [l] CROSS APPLY ( - SELECT TOP(10) [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] + SELECT TOP(10) 1 AS empty FROM [LevelTwo] AS [l0] WHERE [l].[Id] = [l0].[Level1_Optional_Id] AND [l0].[Id] > 0 ORDER BY [l0].[Id] @@ -4008,7 +4008,7 @@ public override async Task Distinct_skip_without_orderby(bool async) SELECT ( SELECT TOP(1) [t0].[Name] FROM ( - SELECT [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] + SELECT [t].[Id], [t].[Name] FROM ( SELECT DISTINCT [l0].[Id], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id] FROM [LevelThree] AS [l0] @@ -4293,7 +4293,7 @@ public override async Task Prune_does_not_throw_null_ref(bool async) """ SELECT [t0].[Id], [t0].[Date], [t0].[Name], [t0].[OneToMany_Optional_Self_Inverse1Id], [t0].[OneToMany_Required_Self_Inverse1Id], [t0].[OneToOne_Optional_Self1Id] FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e] LEFT JOIN ( SELECT [l].[Level1_Required_Id] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs index e6aeb21aef6..780481f5805 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs @@ -135,14 +135,14 @@ WHEN [t3].[OneToOne_Required_PK_Date] IS NOT NULL AND [t3].[Level1_Required_Id] END, 0)) FROM [Level1] AS [l2] LEFT JOIN ( - SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Level2_Name], [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Required_Id], [l3].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l3] WHERE [l3].[OneToOne_Required_PK_Date] IS NOT NULL AND [l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t1] ON [l2].[Id] = CASE WHEN [t1].[OneToOne_Required_PK_Date] IS NOT NULL AND [t1].[Level1_Required_Id] IS NOT NULL AND [t1].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [t1].[Id] END LEFT JOIN ( - SELECT [l4].[Id], [l4].[Level2_Optional_Id], [l4].[Level2_Required_Id], [l4].[Level3_Name], [l4].[OneToMany_Optional_Inverse3Id], [l4].[OneToMany_Required_Inverse3Id], [l4].[OneToOne_Optional_PK_Inverse3Id] + SELECT [l4].[Id], [l4].[Level2_Required_Id], [l4].[Level3_Name], [l4].[OneToMany_Required_Inverse3Id] FROM [Level1] AS [l4] WHERE [l4].[Level2_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse3Id] IS NOT NULL ) AS [t2] ON CASE @@ -151,7 +151,7 @@ WHEN [t1].[OneToOne_Required_PK_Date] IS NOT NULL AND [t1].[Level1_Required_Id] WHEN [t2].[Level2_Required_Id] IS NOT NULL AND [t2].[OneToMany_Required_Inverse3Id] IS NOT NULL THEN [t2].[Id] END LEFT JOIN ( - SELECT [l5].[Id], [l5].[OneToOne_Required_PK_Date], [l5].[Level1_Optional_Id], [l5].[Level1_Required_Id], [l5].[Level2_Name], [l5].[OneToMany_Optional_Inverse2Id], [l5].[OneToMany_Required_Inverse2Id], [l5].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l5].[Id], [l5].[OneToOne_Required_PK_Date], [l5].[Level1_Required_Id], [l5].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l5] WHERE [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t3] ON [l2].[Id] = CASE @@ -450,14 +450,14 @@ WHEN [t3].[OneToOne_Required_PK_Date] IS NOT NULL AND [t3].[Level1_Required_Id] END, 0)) FROM [Level1] AS [l2] LEFT JOIN ( - SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Level2_Name], [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Required_Id], [l3].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l3] WHERE [l3].[OneToOne_Required_PK_Date] IS NOT NULL AND [l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t1] ON [l2].[Id] = CASE WHEN [t1].[OneToOne_Required_PK_Date] IS NOT NULL AND [t1].[Level1_Required_Id] IS NOT NULL AND [t1].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [t1].[Id] END LEFT JOIN ( - SELECT [l4].[Id], [l4].[Level2_Optional_Id], [l4].[Level2_Required_Id], [l4].[Level3_Name], [l4].[OneToMany_Optional_Inverse3Id], [l4].[OneToMany_Required_Inverse3Id], [l4].[OneToOne_Optional_PK_Inverse3Id] + SELECT [l4].[Id], [l4].[Level2_Required_Id], [l4].[Level3_Name], [l4].[OneToMany_Required_Inverse3Id] FROM [Level1] AS [l4] WHERE [l4].[Level2_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse3Id] IS NOT NULL ) AS [t2] ON CASE @@ -466,7 +466,7 @@ WHEN [t1].[OneToOne_Required_PK_Date] IS NOT NULL AND [t1].[Level1_Required_Id] WHEN [t2].[Level2_Required_Id] IS NOT NULL AND [t2].[OneToMany_Required_Inverse3Id] IS NOT NULL THEN [t2].[Id] END LEFT JOIN ( - SELECT [l5].[Id], [l5].[OneToOne_Required_PK_Date], [l5].[Level1_Optional_Id], [l5].[Level1_Required_Id], [l5].[Level2_Name], [l5].[OneToMany_Optional_Inverse2Id], [l5].[OneToMany_Required_Inverse2Id], [l5].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l5].[Id], [l5].[OneToOne_Required_PK_Date], [l5].[Level1_Required_Id], [l5].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l5] WHERE [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t3] ON [l2].[Id] = CASE @@ -516,7 +516,7 @@ SELECT TOP(1) [t1].[Level3_Name] SELECT DISTINCT TOP(1) [t0].[Id], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Level3_Name], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id] FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Level2_Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Required_Id], [l1].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l1] WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l0].[Id] = CASE @@ -758,7 +758,7 @@ WHEN EXISTS ( SELECT 1 FROM [Level1] AS [l] LEFT JOIN ( - SELECT [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l0] WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l].[Id] = [t].[Level1_Optional_Id] @@ -825,12 +825,12 @@ SELECT COALESCE(SUM(CASE WHEN [t3].[OneToOne_Required_PK_Date] IS NOT NULL AND [t3].[Level1_Required_Id] IS NOT NULL AND [t3].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [t3].[Id] END), 0) FROM ( - SELECT [l1].[Id], [l1].[Date], [l1].[Name], [t4].[Id] AS [Id0], [t4].[OneToOne_Required_PK_Date], [t4].[Level1_Optional_Id], [t4].[Level1_Required_Id], [t4].[Level2_Name], [t4].[OneToMany_Optional_Inverse2Id], [t4].[OneToMany_Required_Inverse2Id], [t4].[OneToOne_Optional_PK_Inverse2Id], CASE + SELECT [l1].[Id], CASE WHEN [t4].[OneToOne_Required_PK_Date] IS NOT NULL AND [t4].[Level1_Required_Id] IS NOT NULL AND [t4].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [t4].[Id] END % 3 AS [Key] FROM [Level1] AS [l1] LEFT JOIN ( - SELECT [l2].[Id], [l2].[OneToOne_Required_PK_Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Level2_Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l2].[Id], [l2].[OneToOne_Required_PK_Date], [l2].[Level1_Required_Id], [l2].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l2] WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t4] ON [l1].[Id] = CASE @@ -839,7 +839,7 @@ WHEN [t4].[OneToOne_Required_PK_Date] IS NOT NULL AND [t4].[Level1_Required_Id] WHERE [t4].[OneToOne_Required_PK_Date] IS NOT NULL AND [t4].[Level1_Required_Id] IS NOT NULL AND [t4].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t2] LEFT JOIN ( - SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Level2_Name], [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Required_Id], [l3].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l3] WHERE [l3].[OneToOne_Required_PK_Date] IS NOT NULL AND [l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t3] ON [t2].[Id] = CASE @@ -879,7 +879,7 @@ WHEN EXISTS ( SELECT 1 FROM [Level1] AS [l2] LEFT JOIN ( - SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Level2_Name], [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l3] WHERE [l3].[OneToOne_Required_PK_Date] IS NOT NULL AND [l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t1] ON [l2].[Id] = [t1].[Level1_Optional_Id] @@ -988,10 +988,10 @@ public override async Task Union_over_entities_with_different_nullability(bool a SELECT [l].[Id] FROM [Level1] AS [l] LEFT JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Name], [t].[Id] AS [Id0], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id] + SELECT [t].[Level1_Optional_Id] FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Level2_Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l1] WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l0].[Id] = CASE @@ -1023,12 +1023,12 @@ public override async Task Distinct_skip_without_orderby(bool async) SELECT ( SELECT TOP(1) [t2].[Level3_Name] FROM ( - SELECT [t1].[Id], [t1].[Level2_Optional_Id], [t1].[Level2_Required_Id], [t1].[Level3_Name], [t1].[OneToMany_Optional_Inverse3Id], [t1].[OneToMany_Required_Inverse3Id], [t1].[OneToOne_Optional_PK_Inverse3Id] + SELECT [t1].[Id], [t1].[Level2_Required_Id], [t1].[Level3_Name], [t1].[OneToMany_Required_Inverse3Id] FROM ( SELECT DISTINCT [t0].[Id], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Level3_Name], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id] FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Level2_Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Required_Id], [l1].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l1] WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l0].[Id] = CASE @@ -1105,7 +1105,7 @@ WHEN EXISTS ( SELECT 1 FROM [Level1] AS [l1] LEFT JOIN ( - SELECT [l2].[Id], [l2].[OneToOne_Required_PK_Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Level2_Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l2].[Level1_Optional_Id], [l2].[Level2_Name] FROM [Level1] AS [l2] WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t0] ON [l1].[Id] = [t0].[Level1_Optional_Id] @@ -1228,7 +1228,7 @@ WHEN EXISTS ( SELECT 1 FROM [Level1] AS [l] LEFT JOIN ( - SELECT [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l0] WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l].[Id] = [t].[Level1_Optional_Id] @@ -1443,7 +1443,7 @@ public override async Task Prune_does_not_throw_null_ref(bool async) """ SELECT [t1].[Id], [t1].[Date], [t1].[Name] FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e] LEFT JOIN ( SELECT [t].[Level1_Required_Id] @@ -1756,7 +1756,7 @@ WHEN [t1].[OneToOne_Required_PK_Date] IS NOT NULL AND [t1].[Level1_Required_Id] END FROM [Level1] AS [l2] LEFT JOIN ( - SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Level2_Name], [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Required_Id], [l3].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l3] WHERE [l3].[OneToOne_Required_PK_Date] IS NOT NULL AND [l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t1] ON [l2].[Id] = CASE @@ -2036,7 +2036,7 @@ public override async Task Required_navigation_on_a_subquery_with_complex_projec SELECT TOP(1) [l3].[Name] FROM [Level1] AS [l1] LEFT JOIN ( - SELECT [l4].[Id], [l4].[OneToOne_Required_PK_Date], [l4].[Level1_Optional_Id], [l4].[Level1_Required_Id], [l4].[Level2_Name], [l4].[OneToMany_Optional_Inverse2Id], [l4].[OneToMany_Required_Inverse2Id], [l4].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l4].[Id], [l4].[OneToOne_Required_PK_Date], [l4].[Level1_Required_Id], [l4].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l4] WHERE [l4].[OneToOne_Required_PK_Date] IS NOT NULL AND [l4].[Level1_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t0] ON [l1].[Id] = CASE @@ -2130,7 +2130,7 @@ WHEN [t].[OneToOne_Required_PK_Date] IS NOT NULL AND [t].[Level1_Required_Id] IS SELECT TOP(1) [l2].[Name] FROM [Level1] AS [l1] LEFT JOIN ( - SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Level2_Name], [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Required_Id], [l3].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l3] WHERE [l3].[OneToOne_Required_PK_Date] IS NOT NULL AND [l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t0] ON [l1].[Id] = CASE @@ -2144,7 +2144,7 @@ WHEN [t0].[OneToOne_Required_PK_Date] IS NOT NULL AND [t0].[Level1_Required_Id] SELECT TOP(1) [l5].[Name] FROM [Level1] AS [l4] LEFT JOIN ( - SELECT [l6].[Id], [l6].[OneToOne_Required_PK_Date], [l6].[Level1_Optional_Id], [l6].[Level1_Required_Id], [l6].[Level2_Name], [l6].[OneToMany_Optional_Inverse2Id], [l6].[OneToMany_Required_Inverse2Id], [l6].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l6].[Id], [l6].[OneToOne_Required_PK_Date], [l6].[Level1_Required_Id], [l6].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l6] WHERE [l6].[OneToOne_Required_PK_Date] IS NOT NULL AND [l6].[Level1_Required_Id] IS NOT NULL AND [l6].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t1] ON [l4].[Id] = CASE @@ -2355,7 +2355,7 @@ public override async Task Required_navigation_on_a_subquery_with_First_in_proje SELECT TOP(1) [l2].[Name] FROM [Level1] AS [l1] LEFT JOIN ( - SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Level2_Name], [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Required_Id], [l3].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l3] WHERE [l3].[OneToOne_Required_PK_Date] IS NOT NULL AND [l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t0] ON [l1].[Id] = CASE @@ -2563,10 +2563,10 @@ SELECT [t2].[Level2_Name] SELECT TOP(@__p_0) [l].[Id] FROM [Level1] AS [l] LEFT JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Name], [t].[Id] AS [Id0], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id] + SELECT [t].[Level1_Optional_Id] FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Level2_Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l1] WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l0].[Id] = CASE @@ -2871,17 +2871,17 @@ WHEN [t].[OneToOne_Required_PK_Date] IS NOT NULL AND [t].[Level1_Required_Id] IS END INNER JOIN [Level1] AS [l1] ON [t].[Level1_Required_Id] = [l1].[Id] INNER JOIN ( - SELECT [l2].[Id], [l2].[Date], [l2].[Name], [t0].[Id] AS [Id0], [t0].[OneToOne_Required_PK_Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Level2_Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t2].[Id] AS [Id1], [t2].[Level2_Optional_Id], [t2].[Level2_Required_Id], [t2].[Level3_Name], [t2].[OneToMany_Optional_Inverse3Id], [t2].[OneToMany_Required_Inverse3Id], [t2].[OneToOne_Optional_PK_Inverse3Id] + SELECT [t2].[Level2_Required_Id] FROM [Level1] AS [l2] LEFT JOIN ( - SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Level2_Name], [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Required_Id], [l3].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l3] WHERE [l3].[OneToOne_Required_PK_Date] IS NOT NULL AND [l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t0] ON [l2].[Id] = CASE WHEN [t0].[OneToOne_Required_PK_Date] IS NOT NULL AND [t0].[Level1_Required_Id] IS NOT NULL AND [t0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [t0].[Id] END LEFT JOIN ( - SELECT [l4].[Id], [l4].[Level2_Optional_Id], [l4].[Level2_Required_Id], [l4].[Level3_Name], [l4].[OneToMany_Optional_Inverse3Id], [l4].[OneToMany_Required_Inverse3Id], [l4].[OneToOne_Optional_PK_Inverse3Id] + SELECT [l4].[Id], [l4].[Level2_Required_Id], [l4].[OneToMany_Required_Inverse3Id] FROM [Level1] AS [l4] WHERE [l4].[Level2_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse3Id] IS NOT NULL ) AS [t2] ON CASE @@ -3903,7 +3903,7 @@ WHERE EXISTS ( SELECT 1 FROM [Level1] AS [l3] LEFT JOIN ( - SELECT [l4].[Id], [l4].[OneToOne_Required_PK_Date], [l4].[Level1_Optional_Id], [l4].[Level1_Required_Id], [l4].[Level2_Name], [l4].[OneToMany_Optional_Inverse2Id], [l4].[OneToMany_Required_Inverse2Id], [l4].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l4].[Id], [l4].[OneToOne_Required_PK_Date], [l4].[Level1_Required_Id], [l4].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l4] WHERE [l4].[OneToOne_Required_PK_Date] IS NOT NULL AND [l4].[Level1_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t1] ON [l3].[Id] = CASE @@ -4021,10 +4021,10 @@ SELECT COUNT(*) SELECT DISTINCT [l0].[Id], [l0].[Date], [l0].[Name] FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[Date], [l1].[Name], [t].[Id] AS [Id0], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id] + SELECT [t].[Level1_Optional_Id] FROM [Level1] AS [l1] LEFT JOIN ( - SELECT [l2].[Id], [l2].[OneToOne_Required_PK_Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Level2_Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l2].[Id], [l2].[OneToOne_Required_PK_Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l2] WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l1].[Id] = CASE @@ -4341,7 +4341,7 @@ WHERE EXISTS ( SELECT 1 FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Level2_Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Required_Id], [l1].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l1] WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l0].[Id] = CASE @@ -4351,14 +4351,14 @@ WHERE [t].[OneToOne_Required_PK_Date] IS NOT NULL AND [t].[Level1_Required_Id] I SELECT 1 FROM [Level1] AS [l2] LEFT JOIN ( - SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Level2_Name], [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Required_Id], [l3].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l3] WHERE [l3].[OneToOne_Required_PK_Date] IS NOT NULL AND [l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t0] ON [l2].[Id] = CASE WHEN [t0].[OneToOne_Required_PK_Date] IS NOT NULL AND [t0].[Level1_Required_Id] IS NOT NULL AND [t0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [t0].[Id] END LEFT JOIN ( - SELECT [l4].[Id], [l4].[Level2_Optional_Id], [l4].[Level2_Required_Id], [l4].[Level3_Name], [l4].[OneToMany_Optional_Inverse3Id], [l4].[OneToMany_Required_Inverse3Id], [l4].[OneToOne_Optional_PK_Inverse3Id] + SELECT [l4].[Id], [l4].[Level2_Required_Id], [l4].[OneToMany_Required_Inverse3Id] FROM [Level1] AS [l4] WHERE [l4].[Level2_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse3Id] IS NOT NULL ) AS [t1] ON CASE @@ -4672,10 +4672,10 @@ public override async Task GroupJoin_without_DefaultIfEmpty(bool async) SELECT [l].[Id] FROM [Level1] AS [l] INNER JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Name], [t].[Id] AS [Id0], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id] + SELECT [t].[Level1_Optional_Id] FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Level2_Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l1] WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l0].[Id] = CASE @@ -4934,10 +4934,10 @@ FROM [Level1] AS [l] SELECT COUNT(*) FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[Date], [l1].[Name], [t].[Id] AS [Id0], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id] + SELECT [t].[Level1_Optional_Id] FROM [Level1] AS [l1] LEFT JOIN ( - SELECT [l2].[Id], [l2].[OneToOne_Required_PK_Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Level2_Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l2].[Id], [l2].[OneToOne_Required_PK_Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l2] WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l1].[Id] = CASE @@ -4980,24 +4980,24 @@ WHEN [t2].[Level2_Required_Id] IS NOT NULL AND [t2].[OneToMany_Required_Inverse3 END FROM [Level1] AS [l3] LEFT JOIN ( - SELECT [l4].[Id], [l4].[OneToOne_Required_PK_Date], [l4].[Level1_Optional_Id], [l4].[Level1_Required_Id], [l4].[Level2_Name], [l4].[OneToMany_Optional_Inverse2Id], [l4].[OneToMany_Required_Inverse2Id], [l4].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l4].[Id], [l4].[OneToOne_Required_PK_Date], [l4].[Level1_Required_Id], [l4].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l4] WHERE [l4].[OneToOne_Required_PK_Date] IS NOT NULL AND [l4].[Level1_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t1] ON [l3].[Id] = CASE WHEN [t1].[OneToOne_Required_PK_Date] IS NOT NULL AND [t1].[Level1_Required_Id] IS NOT NULL AND [t1].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [t1].[Id] END LEFT JOIN ( - SELECT [l5].[Id], [l5].[Date], [l5].[Name], [t3].[Id] AS [Id0], [t3].[OneToOne_Required_PK_Date], [t3].[Level1_Optional_Id], [t3].[Level1_Required_Id], [t3].[Level2_Name], [t3].[OneToMany_Optional_Inverse2Id], [t3].[OneToMany_Required_Inverse2Id], [t3].[OneToOne_Optional_PK_Inverse2Id], [t4].[Id] AS [Id1], [t4].[Level2_Optional_Id], [t4].[Level2_Required_Id], [t4].[Level3_Name], [t4].[OneToMany_Optional_Inverse3Id], [t4].[OneToMany_Required_Inverse3Id], [t4].[OneToOne_Optional_PK_Inverse3Id] + SELECT [t4].[Id] AS [Id1], [t4].[Level2_Optional_Id], [t4].[Level2_Required_Id], [t4].[OneToMany_Required_Inverse3Id] FROM [Level1] AS [l5] LEFT JOIN ( - SELECT [l6].[Id], [l6].[OneToOne_Required_PK_Date], [l6].[Level1_Optional_Id], [l6].[Level1_Required_Id], [l6].[Level2_Name], [l6].[OneToMany_Optional_Inverse2Id], [l6].[OneToMany_Required_Inverse2Id], [l6].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l6].[Id], [l6].[OneToOne_Required_PK_Date], [l6].[Level1_Required_Id], [l6].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l6] WHERE [l6].[OneToOne_Required_PK_Date] IS NOT NULL AND [l6].[Level1_Required_Id] IS NOT NULL AND [l6].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t3] ON [l5].[Id] = CASE WHEN [t3].[OneToOne_Required_PK_Date] IS NOT NULL AND [t3].[Level1_Required_Id] IS NOT NULL AND [t3].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [t3].[Id] END LEFT JOIN ( - SELECT [l7].[Id], [l7].[Level2_Optional_Id], [l7].[Level2_Required_Id], [l7].[Level3_Name], [l7].[OneToMany_Optional_Inverse3Id], [l7].[OneToMany_Required_Inverse3Id], [l7].[OneToOne_Optional_PK_Inverse3Id] + SELECT [l7].[Id], [l7].[Level2_Optional_Id], [l7].[Level2_Required_Id], [l7].[OneToMany_Required_Inverse3Id] FROM [Level1] AS [l7] WHERE [l7].[Level2_Required_Id] IS NOT NULL AND [l7].[OneToMany_Required_Inverse3Id] IS NOT NULL ) AS [t4] ON CASE @@ -5219,17 +5219,17 @@ WHEN [t].[OneToOne_Required_PK_Date] IS NOT NULL AND [t].[Level1_Required_Id] IS END INNER JOIN [Level1] AS [l1] ON [t].[Level1_Required_Id] = [l1].[Id] INNER JOIN ( - SELECT [l2].[Id], [l2].[Date], [l2].[Name], [t0].[Id] AS [Id0], [t0].[OneToOne_Required_PK_Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Level2_Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t2].[Id] AS [Id1], [t2].[Level2_Optional_Id], [t2].[Level2_Required_Id], [t2].[Level3_Name], [t2].[OneToMany_Optional_Inverse3Id], [t2].[OneToMany_Required_Inverse3Id], [t2].[OneToOne_Optional_PK_Inverse3Id] + SELECT [t2].[Level2_Required_Id] FROM [Level1] AS [l2] LEFT JOIN ( - SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Level2_Name], [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Required_Id], [l3].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l3] WHERE [l3].[OneToOne_Required_PK_Date] IS NOT NULL AND [l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t0] ON [l2].[Id] = CASE WHEN [t0].[OneToOne_Required_PK_Date] IS NOT NULL AND [t0].[Level1_Required_Id] IS NOT NULL AND [t0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [t0].[Id] END LEFT JOIN ( - SELECT [l4].[Id], [l4].[Level2_Optional_Id], [l4].[Level2_Required_Id], [l4].[Level3_Name], [l4].[OneToMany_Optional_Inverse3Id], [l4].[OneToMany_Required_Inverse3Id], [l4].[OneToOne_Optional_PK_Inverse3Id] + SELECT [l4].[Id], [l4].[Level2_Required_Id], [l4].[OneToMany_Required_Inverse3Id] FROM [Level1] AS [l4] WHERE [l4].[Level2_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse3Id] IS NOT NULL ) AS [t2] ON CASE @@ -5295,7 +5295,7 @@ SELECT [t1].[Level3_Name] SELECT DISTINCT [t0].[Id], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Level3_Name], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id] FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Level2_Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Required_Id], [l1].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l1] WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l0].[Id] = CASE @@ -5333,7 +5333,7 @@ WHERE EXISTS ( SELECT 1 FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Level2_Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Required_Id], [l1].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l1] WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l0].[Id] = CASE @@ -5343,14 +5343,14 @@ WHERE [t].[OneToOne_Required_PK_Date] IS NOT NULL AND [t].[Level1_Required_Id] I SELECT 1 FROM [Level1] AS [l2] LEFT JOIN ( - SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Level2_Name], [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Required_Id], [l3].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l3] WHERE [l3].[OneToOne_Required_PK_Date] IS NOT NULL AND [l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t0] ON [l2].[Id] = CASE WHEN [t0].[OneToOne_Required_PK_Date] IS NOT NULL AND [t0].[Level1_Required_Id] IS NOT NULL AND [t0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [t0].[Id] END LEFT JOIN ( - SELECT [l4].[Id], [l4].[Level2_Optional_Id], [l4].[Level2_Required_Id], [l4].[Level3_Name], [l4].[OneToMany_Optional_Inverse3Id], [l4].[OneToMany_Required_Inverse3Id], [l4].[OneToOne_Optional_PK_Inverse3Id] + SELECT [l4].[Id], [l4].[Level2_Required_Id], [l4].[OneToMany_Required_Inverse3Id] FROM [Level1] AS [l4] WHERE [l4].[Level2_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse3Id] IS NOT NULL ) AS [t1] ON CASE @@ -5652,10 +5652,10 @@ public override async Task GroupJoin_client_method_on_outer(bool async) SELECT [l].[Id] FROM [Level1] AS [l] LEFT JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Name], [t].[Id] AS [Id0], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id] + SELECT [t].[Level1_Optional_Id] FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Level2_Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l1] WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l0].[Id] = CASE @@ -5689,7 +5689,7 @@ WHERE [l1].[Level2_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse WHEN [t].[OneToOne_Required_PK_Date] IS NOT NULL AND [t].[Level1_Required_Id] IS NOT NULL AND [t].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [t].[Id] END = [t0].[Level2_Required_Id] LEFT JOIN ( - SELECT [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Level3_Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id] + SELECT [l2].[OneToOne_Optional_PK_Inverse3Id] FROM [Level1] AS [l2] WHERE [l2].[Level2_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse3Id] IS NOT NULL ) AS [t1] ON CASE @@ -5861,7 +5861,7 @@ SELECT [t1].[Level3_Name] SELECT DISTINCT [t0].[Id], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Level3_Name], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id] FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Level2_Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Required_Id], [l1].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l1] WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l0].[Id] = CASE @@ -6306,10 +6306,10 @@ FROM [Level1] AS [l] SELECT COUNT(*) FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[Date], [l1].[Name], [t].[Id] AS [Id0], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id] + SELECT [t].[Level1_Optional_Id] FROM [Level1] AS [l1] LEFT JOIN ( - SELECT [l2].[Id], [l2].[OneToOne_Required_PK_Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Level2_Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l2].[Id], [l2].[OneToOne_Required_PK_Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l2] WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l1].[Id] = CASE @@ -6321,10 +6321,10 @@ WHERE [t].[OneToOne_Required_PK_Date] IS NOT NULL AND [t].[Level1_Required_Id] I SELECT COUNT(*) FROM [Level1] AS [l3] LEFT JOIN ( - SELECT [l4].[Id], [l4].[Date], [l4].[Name], [t2].[Id] AS [Id0], [t2].[OneToOne_Required_PK_Date], [t2].[Level1_Optional_Id], [t2].[Level1_Required_Id], [t2].[Level2_Name], [t2].[OneToMany_Optional_Inverse2Id], [t2].[OneToMany_Required_Inverse2Id], [t2].[OneToOne_Optional_PK_Inverse2Id] + SELECT [t2].[Level1_Optional_Id] FROM [Level1] AS [l4] LEFT JOIN ( - SELECT [l5].[Id], [l5].[OneToOne_Required_PK_Date], [l5].[Level1_Optional_Id], [l5].[Level1_Required_Id], [l5].[Level2_Name], [l5].[OneToMany_Optional_Inverse2Id], [l5].[OneToMany_Required_Inverse2Id], [l5].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l5].[Id], [l5].[OneToOne_Required_PK_Date], [l5].[Level1_Optional_Id], [l5].[Level1_Required_Id], [l5].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l5] WHERE [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t2] ON [l4].[Id] = CASE @@ -6382,7 +6382,7 @@ public override async Task Select_subquery_with_client_eval_and_navigation1(bool SELECT TOP(1) [l2].[Name] FROM [Level1] AS [l1] LEFT JOIN ( - SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Level2_Name], [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Required_Id], [l3].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l3] WHERE [l3].[OneToOne_Required_PK_Date] IS NOT NULL AND [l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t0] ON [l1].[Id] = CASE @@ -6447,10 +6447,10 @@ FROM [Level1] AS [l] SELECT COUNT(*) FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[Date], [l1].[Name], [t].[Id] AS [Id0], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id] + SELECT [t].[Level1_Optional_Id] FROM [Level1] AS [l1] LEFT JOIN ( - SELECT [l2].[Id], [l2].[OneToOne_Required_PK_Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Level2_Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l2].[Id], [l2].[OneToOne_Required_PK_Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l2] WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l1].[Id] = CASE @@ -6651,7 +6651,7 @@ WHERE EXISTS ( SELECT 1 FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Level2_Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Required_Id], [l1].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l1] WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l0].[Id] = CASE @@ -6672,7 +6672,7 @@ SELECT CASE SELECT TOP(1) [l2].[Name] FROM [Level1] AS [l1] LEFT JOIN ( - SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Level2_Name], [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Required_Id], [l3].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l3] WHERE [l3].[OneToOne_Required_PK_Date] IS NOT NULL AND [l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t0] ON [l1].[Id] = CASE @@ -6686,7 +6686,7 @@ WHEN [t0].[OneToOne_Required_PK_Date] IS NOT NULL AND [t0].[Level1_Required_Id] SELECT TOP(1) [l2].[Name] FROM [Level1] AS [l1] LEFT JOIN ( - SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Level2_Name], [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l3].[Id], [l3].[OneToOne_Required_PK_Date], [l3].[Level1_Required_Id], [l3].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l3] WHERE [l3].[OneToOne_Required_PK_Date] IS NOT NULL AND [l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t0] ON [l1].[Id] = CASE @@ -7048,14 +7048,14 @@ public override async Task Select_subquery_with_client_eval_and_multi_level_navi SELECT TOP(1) [l3].[Name] FROM [Level1] AS [l2] LEFT JOIN ( - SELECT [l4].[Id], [l4].[OneToOne_Required_PK_Date], [l4].[Level1_Optional_Id], [l4].[Level1_Required_Id], [l4].[Level2_Name], [l4].[OneToMany_Optional_Inverse2Id], [l4].[OneToMany_Required_Inverse2Id], [l4].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l4].[Id], [l4].[OneToOne_Required_PK_Date], [l4].[Level1_Required_Id], [l4].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l4] WHERE [l4].[OneToOne_Required_PK_Date] IS NOT NULL AND [l4].[Level1_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t1] ON [l2].[Id] = CASE WHEN [t1].[OneToOne_Required_PK_Date] IS NOT NULL AND [t1].[Level1_Required_Id] IS NOT NULL AND [t1].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [t1].[Id] END LEFT JOIN ( - SELECT [l5].[Id], [l5].[Level2_Optional_Id], [l5].[Level2_Required_Id], [l5].[Level3_Name], [l5].[OneToMany_Optional_Inverse3Id], [l5].[OneToMany_Required_Inverse3Id], [l5].[OneToOne_Optional_PK_Inverse3Id] + SELECT [l5].[Id], [l5].[Level2_Required_Id], [l5].[OneToMany_Required_Inverse3Id] FROM [Level1] AS [l5] WHERE [l5].[Level2_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse3Id] IS NOT NULL ) AS [t2] ON CASE @@ -7064,7 +7064,7 @@ WHEN [t1].[OneToOne_Required_PK_Date] IS NOT NULL AND [t1].[Level1_Required_Id] WHEN [t2].[Level2_Required_Id] IS NOT NULL AND [t2].[OneToMany_Required_Inverse3Id] IS NOT NULL THEN [t2].[Id] END LEFT JOIN ( - SELECT [l6].[Id], [l6].[OneToOne_Required_PK_Date], [l6].[Level1_Optional_Id], [l6].[Level1_Required_Id], [l6].[Level2_Name], [l6].[OneToMany_Optional_Inverse2Id], [l6].[OneToMany_Required_Inverse2Id], [l6].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l6].[Id], [l6].[OneToOne_Required_PK_Date], [l6].[Level1_Required_Id], [l6].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l6] WHERE [l6].[OneToOne_Required_PK_Date] IS NOT NULL AND [l6].[Level1_Required_Id] IS NOT NULL AND [l6].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t3] ON [t2].[Level2_Required_Id] = CASE @@ -7281,10 +7281,10 @@ SELECT COUNT(*) SELECT DISTINCT [l0].[Id], [l0].[Date], [l0].[Name] FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[Date], [l1].[Name], [t].[Id] AS [Id0], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id] + SELECT [t].[Level1_Optional_Id] FROM [Level1] AS [l1] LEFT JOIN ( - SELECT [l2].[Id], [l2].[OneToOne_Required_PK_Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Level2_Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l2].[Id], [l2].[OneToOne_Required_PK_Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l2] WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l1].[Id] = CASE @@ -7524,13 +7524,13 @@ FROM [Level1] AS [l] WHERE ( SELECT COUNT(*) FROM ( - SELECT TOP(10) [l0].[Id], [t0].[Id] AS [Id0], [t0].[Id0] AS [Id00] + SELECT TOP(10) 1 AS empty FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[Date], [l1].[Name], [t].[Id] AS [Id0], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id] + SELECT [t].[Level1_Optional_Id] FROM [Level1] AS [l1] LEFT JOIN ( - SELECT [l2].[Id], [l2].[OneToOne_Required_PK_Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Level2_Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l2].[Id], [l2].[OneToOne_Required_PK_Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l2] WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l1].[Id] = CASE @@ -7542,10 +7542,10 @@ WHERE [t].[OneToOne_Required_PK_Date] IS NOT NULL AND [t].[Level1_Required_Id] I SELECT COUNT(*) FROM [Level1] AS [l3] LEFT JOIN ( - SELECT [l4].[Id], [l4].[Date], [l4].[Name], [t2].[Id] AS [Id0], [t2].[OneToOne_Required_PK_Date], [t2].[Level1_Optional_Id], [t2].[Level1_Required_Id], [t2].[Level2_Name], [t2].[OneToMany_Optional_Inverse2Id], [t2].[OneToMany_Required_Inverse2Id], [t2].[OneToOne_Optional_PK_Inverse2Id] + SELECT [t2].[Level1_Optional_Id] FROM [Level1] AS [l4] LEFT JOIN ( - SELECT [l5].[Id], [l5].[OneToOne_Required_PK_Date], [l5].[Level1_Optional_Id], [l5].[Level1_Required_Id], [l5].[Level2_Name], [l5].[OneToMany_Optional_Inverse2Id], [l5].[OneToMany_Required_Inverse2Id], [l5].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l5].[Id], [l5].[OneToOne_Required_PK_Date], [l5].[Level1_Optional_Id], [l5].[Level1_Required_Id], [l5].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l5] WHERE [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t2] ON [l4].[Id] = CASE @@ -7639,12 +7639,10 @@ public override async Task GroupJoin_with_subquery_on_inner(bool async) SELECT [l].[Id] FROM [Level1] AS [l] OUTER APPLY ( - SELECT TOP(10) [t].[Id], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [l0].[Id] AS [Id0], CASE - WHEN [t].[OneToOne_Required_PK_Date] IS NOT NULL AND [t].[Level1_Required_Id] IS NOT NULL AND [t].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [t].[Id] - END AS [c] + SELECT TOP(10) 1 AS empty FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Level2_Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l1] WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l0].[Id] = CASE @@ -7669,12 +7667,10 @@ public override async Task GroupJoin_with_subquery_on_inner_and_no_DefaultIfEmpt SELECT [l].[Id] FROM [Level1] AS [l] CROSS APPLY ( - SELECT TOP(10) [t].[Id], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [l0].[Id] AS [Id0], CASE - WHEN [t].[OneToOne_Required_PK_Date] IS NOT NULL AND [t].[Level1_Required_Id] IS NOT NULL AND [t].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [t].[Id] - END AS [c] + SELECT TOP(10) 1 AS empty FROM [Level1] AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Level2_Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id] + SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[OneToMany_Required_Inverse2Id] FROM [Level1] AS [l1] WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL ) AS [t] ON [l0].[Id] = CASE @@ -8332,7 +8328,7 @@ public override async Task Multiple_select_many_in_projection(bool async) SELECT COUNT(*) FROM [Level1] AS [l3] INNER JOIN ( - SELECT [l4].[Id], [l4].[Level2_Optional_Id], [l4].[Level2_Required_Id], [l4].[Level3_Name], [l4].[OneToMany_Optional_Inverse3Id], [l4].[OneToMany_Required_Inverse3Id], [l4].[OneToOne_Optional_PK_Inverse3Id] + SELECT [l4].[Level3_Name], [l4].[OneToMany_Optional_Inverse3Id] FROM [Level1] AS [l4] WHERE [l4].[Level2_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse3Id] IS NOT NULL ) AS [t3] ON CASE diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Ef6GroupBySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Ef6GroupBySqlServerTest.cs index 1e47c128b6e..a5a7269e4b1 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/Ef6GroupBySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Ef6GroupBySqlServerTest.cs @@ -653,7 +653,7 @@ public override async Task Whats_new_2021_sample_8(bool async) """ SELECT COUNT(*) FROM ( - SELECT [f].[Id], [f].[Size] + SELECT 1 AS empty FROM [Person] AS [p] LEFT JOIN [Feet] AS [f] ON [p].[Id] = [f].[Id] GROUP BY [f].[Id], [f].[Size] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs index f1914a77053..be5e6f263a2 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs @@ -1738,7 +1738,7 @@ FROM [Gears] AS [g] SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] INNER JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + SELECT [w0].[Id] FROM [Weapons] AS [w0] WHERE [g].[FullName] = [w0].[OwnerFullName] ) AS [t] ON [w].[Id] = [t].[Id] @@ -1759,7 +1759,7 @@ FROM [Gears] AS [g] SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + SELECT [w0].[Id] FROM [Weapons] AS [w0] WHERE [g].[FullName] = [w0].[OwnerFullName] ) AS [t] ON [w].[Id] = [t].[Id] @@ -1779,11 +1779,11 @@ FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND ( SELECT TOP(1) [t].[IsAutomatic] FROM ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + SELECT [w].[Id], [w].[IsAutomatic] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] UNION ALL - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + SELECT [w0].[Id], [w0].[IsAutomatic] FROM [Weapons] AS [w0] WHERE [g].[FullName] = [w0].[OwnerFullName] ) AS [t] @@ -1799,10 +1799,10 @@ public override async Task Concat_with_count(bool async) """ SELECT COUNT(*) FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] + SELECT 1 AS empty FROM [Gears] AS [g] UNION ALL - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] + SELECT 1 AS empty FROM [Gears] AS [g0] ) AS [t] """); @@ -1816,10 +1816,10 @@ public override async Task Concat_scalars_with_count(bool async) """ SELECT COUNT(*) FROM ( - SELECT [g].[Nickname] + SELECT 1 AS empty FROM [Gears] AS [g] UNION ALL - SELECT [g0].[FullName] AS [Nickname] + SELECT 1 AS empty FROM [Gears] AS [g0] ) AS [t] """); @@ -1833,10 +1833,10 @@ public override async Task Concat_anonymous_with_count(bool async) """ SELECT COUNT(*) FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g].[Nickname] AS [Name] + SELECT 1 AS empty FROM [Gears] AS [g] UNION ALL - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [g0].[FullName] AS [Name] + SELECT 1 AS empty FROM [Gears] AS [g0] ) AS [t] """); @@ -1865,11 +1865,11 @@ public override async Task Select_navigation_with_concat_and_count(bool async) SELECT ( SELECT COUNT(*) FROM ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + SELECT 1 AS empty FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] UNION ALL - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + SELECT 1 AS empty FROM [Weapons] AS [w0] WHERE [g].[FullName] = [w0].[OwnerFullName] ) AS [t]) @@ -10129,26 +10129,20 @@ FROM [Gears] AS [g2] INNER JOIN [Squads] AS [s0] ON [g2].[SquadId] = [s0].[Id] INNER JOIN [Cities] AS [c] ON [g2].[CityOfBirthName] = [c].[Name] WHERE N'Marcus' IN ( - SELECT [t0].[Nickname] - FROM ( - SELECT [g3].[Nickname], [g3].[SquadId], [g3].[AssignedCityName], [g3].[CityOfBirthName], [g3].[Discriminator], [g3].[FullName], [g3].[HasSoulPatch], [g3].[LeaderNickname], [g3].[LeaderSquadId], [g3].[Rank] - FROM [Gears] AS [g3] - UNION ALL - SELECT [g4].[Nickname], [g4].[SquadId], [g4].[AssignedCityName], [g4].[CityOfBirthName], [g4].[Discriminator], [g4].[FullName], [g4].[HasSoulPatch], [g4].[LeaderNickname], [g4].[LeaderSquadId], [g4].[Rank] - FROM [Gears] AS [g4] - ) AS [t0] + SELECT [g3].[Nickname] + FROM [Gears] AS [g3] + UNION ALL + SELECT [g4].[Nickname] + FROM [Gears] AS [g4] ) AND ([s].[Name] = [s0].[Name] OR ([s].[Name] IS NULL AND [s0].[Name] IS NULL))) AS [SumOfLengths] FROM [Gears] AS [g] INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] WHERE N'Marcus' IN ( - SELECT [t].[Nickname] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] - FROM [Gears] AS [g0] - UNION ALL - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] - FROM [Gears] AS [g1] - ) AS [t] + SELECT [g0].[Nickname] + FROM [Gears] AS [g0] + UNION ALL + SELECT [g1].[Nickname] + FROM [Gears] AS [g1] ) GROUP BY [s].[Name] """); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/JsonQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/JsonQuerySqlServerTest.cs index 033bc798c04..4da558d5c62 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/JsonQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/JsonQuerySqlServerTest.cs @@ -1053,7 +1053,7 @@ FROM [JsonEntitiesBasic] AS [j] WHERE ( SELECT [t].[c] FROM ( - SELECT JSON_VALUE([o].[value], '$.OwnedReferenceLeaf.SomethingSomething') AS [c], [o].[key], CAST([o].[key] AS int) AS [c0] + SELECT JSON_VALUE([o].[value], '$.OwnedReferenceLeaf.SomethingSomething') AS [c], CAST([o].[key] AS int) AS [c0] FROM OPENJSON([j].[OwnedReferenceRoot], '$.OwnedCollectionBranch') AS [o] ORDER BY CAST([o].[key] AS int) OFFSET 1 ROWS @@ -1074,9 +1074,18 @@ FROM [JsonEntitiesBasic] AS [j] WHERE ( SELECT [t].[c] FROM ( - SELECT JSON_VALUE([o].[value], '$.OwnedReferenceLeaf.SomethingSomething') AS [c], [o].[key], CAST(JSON_VALUE([o].[value], '$.Date') AS datetime2) AS [c0] - FROM OPENJSON([j].[OwnedReferenceRoot], '$.OwnedCollectionBranch') AS [o] - ORDER BY CAST(JSON_VALUE([o].[value], '$.Date') AS datetime2) DESC + SELECT JSON_VALUE([o].[OwnedReferenceLeaf], '$.SomethingSomething') AS [c], [o].[Date] AS [c0] + FROM OPENJSON([j].[OwnedReferenceRoot], '$.OwnedCollectionBranch') WITH ( + [Date] datetime2 '$.Date', + [Enum] int '$.Enum', + [Enums] nvarchar(max) '$.Enums' AS JSON, + [Fraction] decimal(18,2) '$.Fraction', + [NullableEnum] int '$.NullableEnum', + [NullableEnums] nvarchar(max) '$.NullableEnums' AS JSON, + [OwnedCollectionLeaf] nvarchar(max) '$.OwnedCollectionLeaf' AS JSON, + [OwnedReferenceLeaf] nvarchar(max) '$.OwnedReferenceLeaf' AS JSON + ) AS [o] + ORDER BY [o].[Date] DESC OFFSET 1 ROWS ) AS [t] ORDER BY [t].[c0] DESC @@ -2012,7 +2021,7 @@ public override async Task Group_by_json_scalar_Skip_First_project_json_scalar(b SELECT ( SELECT TOP(1) CAST(JSON_VALUE([t0].[c0], '$.OwnedReferenceBranch.Enum') AS int) FROM ( - SELECT [j0].[Id], [j0].[EntityBasicId], [j0].[Name], [j0].[OwnedCollectionRoot] AS [c], [j0].[OwnedReferenceRoot] AS [c0], JSON_VALUE([j0].[OwnedReferenceRoot], '$.Name') AS [Key] + SELECT [j0].[OwnedReferenceRoot] AS [c0], JSON_VALUE([j0].[OwnedReferenceRoot], '$.Name') AS [Key] FROM [JsonEntitiesBasic] AS [j0] ) AS [t0] WHERE [t].[Key] = [t0].[Key] OR ([t].[Key] IS NULL AND [t0].[Key] IS NULL)) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyNoTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyNoTrackingQuerySqlServerTest.cs index 7693e2e1bac..4c0f9191a74 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyNoTrackingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyNoTrackingQuerySqlServerTest.cs @@ -108,7 +108,7 @@ ORDER BY ( SELECT COUNT(*) FROM [JoinOneToBranch] AS [j] INNER JOIN ( - SELECT [e0].[Id], [e0].[Discriminator], [e0].[Name], [e0].[Number], [e0].[IsGreen] + SELECT [e0].[Id], [e0].[Name] FROM [EntityRoots] AS [e0] WHERE [e0].[Discriminator] IN (N'EntityBranch', N'EntityLeaf') ) AS [t] ON [j].[EntityBranchId] = [t].[Id] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerTest.cs index 3aaec0746bc..85f679b4c1f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerTest.cs @@ -107,7 +107,7 @@ ORDER BY ( SELECT COUNT(*) FROM [JoinOneToBranch] AS [j] INNER JOIN ( - SELECT [e0].[Id], [e0].[Discriminator], [e0].[Name], [e0].[Number], [e0].[IsGreen] + SELECT [e0].[Id], [e0].[Name] FROM [EntityRoots] AS [e0] WHERE [e0].[Discriminator] IN (N'EntityBranch', N'EntityLeaf') ) AS [t] ON [j].[EntityBranchId] = [t].[Id] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NonSharedPrimitiveCollectionsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NonSharedPrimitiveCollectionsQuerySqlServerTest.cs index 28703f1f91d..7533ca8eea2 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NonSharedPrimitiveCollectionsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NonSharedPrimitiveCollectionsQuerySqlServerTest.cs @@ -331,7 +331,7 @@ FROM [TestEntity] AS [t] WHERE ( SELECT COUNT(*) FROM ( - SELECT [s].[value], [s].[key], CAST([s].[key] AS int) AS [c] + SELECT [s].[value] FROM OPENJSON([t].[SomeArray]) AS [s] ORDER BY CAST([s].[key] AS int) OFFSET 1 ROWS @@ -352,7 +352,7 @@ FROM [TestEntity] AS [t] WHERE ( SELECT COUNT(*) FROM ( - SELECT CAST([s].[value] AS int) AS [value], [s].[key], CAST([s].[key] AS int) AS [c] + SELECT CAST([s].[value] AS int) AS [value] FROM OPENJSON([t].[SomeArray]) AS [s] ORDER BY CAST([s].[key] AS int) OFFSET 1 ROWS @@ -373,7 +373,7 @@ FROM [TestEntity] AS [t] WHERE ( SELECT COUNT(*) FROM ( - SELECT CAST([s].[value] AS bigint) AS [value], [s].[key], CAST([s].[key] AS int) AS [c] + SELECT CAST([s].[value] AS bigint) AS [value] FROM OPENJSON([t].[SomeArray]) AS [s] ORDER BY CAST([s].[key] AS int) OFFSET 1 ROWS @@ -394,7 +394,7 @@ FROM [TestEntity] AS [t] WHERE ( SELECT COUNT(*) FROM ( - SELECT CAST([s].[value] AS smallint) AS [value], [s].[key], CAST([s].[key] AS int) AS [c] + SELECT CAST([s].[value] AS smallint) AS [value] FROM OPENJSON([t].[SomeArray]) AS [s] ORDER BY CAST([s].[key] AS int) OFFSET 1 ROWS @@ -420,7 +420,7 @@ FROM [TestEntity] AS [t] WHERE ( SELECT COUNT(*) FROM ( - SELECT CAST([s].[value] AS float) AS [value], [s].[key], CAST([s].[key] AS int) AS [c] + SELECT CAST([s].[value] AS float) AS [value] FROM OPENJSON([t].[SomeArray]) AS [s] ORDER BY CAST([s].[key] AS int) OFFSET 1 ROWS @@ -441,7 +441,7 @@ FROM [TestEntity] AS [t] WHERE ( SELECT COUNT(*) FROM ( - SELECT CAST([s].[value] AS real) AS [value], [s].[key], CAST([s].[key] AS int) AS [c] + SELECT CAST([s].[value] AS real) AS [value] FROM OPENJSON([t].[SomeArray]) AS [s] ORDER BY CAST([s].[key] AS int) OFFSET 1 ROWS @@ -462,7 +462,7 @@ FROM [TestEntity] AS [t] WHERE ( SELECT COUNT(*) FROM ( - SELECT CAST([s].[value] AS decimal(18,2)) AS [value], [s].[key], CAST([s].[key] AS int) AS [c] + SELECT CAST([s].[value] AS decimal(18,2)) AS [value] FROM OPENJSON([t].[SomeArray]) AS [s] ORDER BY CAST([s].[key] AS int) OFFSET 1 ROWS @@ -483,7 +483,7 @@ FROM [TestEntity] AS [t] WHERE ( SELECT COUNT(*) FROM ( - SELECT CAST([s].[value] AS datetime2) AS [value], [s].[key], CAST([s].[key] AS int) AS [c] + SELECT CAST([s].[value] AS datetime2) AS [value] FROM OPENJSON([t].[SomeArray]) AS [s] ORDER BY CAST([s].[key] AS int) OFFSET 1 ROWS @@ -504,7 +504,7 @@ FROM [TestEntity] AS [t] WHERE ( SELECT COUNT(*) FROM ( - SELECT CAST([s].[value] AS date) AS [value], [s].[key], CAST([s].[key] AS int) AS [c] + SELECT CAST([s].[value] AS date) AS [value] FROM OPENJSON([t].[SomeArray]) AS [s] ORDER BY CAST([s].[key] AS int) OFFSET 1 ROWS @@ -525,7 +525,7 @@ FROM [TestEntity] AS [t] WHERE ( SELECT COUNT(*) FROM ( - SELECT CAST([s].[value] AS time) AS [value], [s].[key], CAST([s].[key] AS int) AS [c] + SELECT CAST([s].[value] AS time) AS [value] FROM OPENJSON([t].[SomeArray]) AS [s] ORDER BY CAST([s].[key] AS int) OFFSET 1 ROWS @@ -548,7 +548,7 @@ FROM [TestEntity] AS [t] WHERE ( SELECT COUNT(*) FROM ( - SELECT CAST([s].[value] AS datetimeoffset) AS [value], [s].[key], CAST([s].[key] AS int) AS [c] + SELECT CAST([s].[value] AS datetimeoffset) AS [value] FROM OPENJSON([t].[SomeArray]) AS [s] ORDER BY CAST([s].[key] AS int) OFFSET 1 ROWS @@ -569,7 +569,7 @@ FROM [TestEntity] AS [t] WHERE ( SELECT COUNT(*) FROM ( - SELECT CAST([s].[value] AS bit) AS [value], [s].[key], CAST([s].[key] AS int) AS [c] + SELECT CAST([s].[value] AS bit) AS [value] FROM OPENJSON([t].[SomeArray]) AS [s] ORDER BY CAST([s].[key] AS int) OFFSET 1 ROWS @@ -592,7 +592,7 @@ FROM [TestEntity] AS [t] WHERE ( SELECT COUNT(*) FROM ( - SELECT CAST([s].[value] AS uniqueidentifier) AS [value], [s].[key], CAST([s].[key] AS int) AS [c] + SELECT CAST([s].[value] AS uniqueidentifier) AS [value] FROM OPENJSON([t].[SomeArray]) AS [s] ORDER BY CAST([s].[key] AS int) OFFSET 1 ROWS @@ -622,7 +622,7 @@ FROM [TestEntity] AS [t] WHERE ( SELECT COUNT(*) FROM ( - SELECT CAST([s].[value] AS int) AS [value], [s].[key], CAST([s].[key] AS int) AS [c] + SELECT CAST([s].[value] AS int) AS [value] FROM OPENJSON([t].[SomeArray]) AS [s] ORDER BY CAST([s].[key] AS int) OFFSET 1 ROWS diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs index 16500f9a9a2..f292a077e5b 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs @@ -157,7 +157,7 @@ public override async Task Average_after_default_if_empty_does_not_throw(bool as """ SELECT AVG(CAST(COALESCE([t].[OrderID], 0) AS float)) FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e] LEFT JOIN ( SELECT [o].[OrderID] @@ -175,7 +175,7 @@ public override async Task Max_after_default_if_empty_does_not_throw(bool async) """ SELECT MAX(COALESCE([t].[OrderID], 0)) FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e] LEFT JOIN ( SELECT [o].[OrderID] @@ -193,7 +193,7 @@ public override async Task Min_after_default_if_empty_does_not_throw(bool async) """ SELECT MIN(COALESCE([t].[OrderID], 0)) FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e] LEFT JOIN ( SELECT [o].[OrderID] @@ -2780,7 +2780,7 @@ public override async Task DefaultIfEmpty_selects_only_required_columns(bool asy """ SELECT [p].[ProductName] FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e] LEFT JOIN [Products] AS [p] ON 1 = 1 """); @@ -2875,7 +2875,7 @@ public override async Task Count_after_client_projection(bool async) SELECT COUNT(*) FROM ( - SELECT TOP(@__p_0) [o].[OrderID] + SELECT TOP(@__p_0) 1 AS empty FROM [Orders] AS [o] ) AS [t] """); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs index 9c92d973afb..92ec01fea92 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs @@ -1767,7 +1767,7 @@ public override async Task GroupBy_Aggregate_Join_converted_from_SelectMany(bool 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].[CustomerID], MAX([o].[OrderID]) AS [LastOrderID] + SELECT [o].[CustomerID] FROM [Orders] AS [o] GROUP BY [o].[CustomerID] HAVING COUNT(*) > 5 @@ -1784,7 +1784,7 @@ public override async Task GroupBy_Aggregate_LeftJoin_converted_from_SelectMany( 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] LEFT JOIN ( - SELECT [o].[CustomerID], MAX([o].[OrderID]) AS [LastOrderID] + SELECT [o].[CustomerID] FROM [Orders] AS [o] GROUP BY [o].[CustomerID] HAVING COUNT(*) > 5 @@ -1895,7 +1895,7 @@ INNER JOIN ( 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 [o0].[CustomerID], MAX([o0].[OrderID]) AS [LastOrderID] + SELECT [o0].[CustomerID] FROM [Orders] AS [o0] GROUP BY [o0].[CustomerID] HAVING COUNT(*) > 5 @@ -2448,7 +2448,7 @@ public override async Task Count_after_GroupBy_aggregate(bool async) """ SELECT COUNT(*) FROM ( - SELECT [o].[CustomerID] + SELECT 1 AS empty FROM [Orders] AS [o] GROUP BY [o].[CustomerID] ) AS [t] @@ -2463,7 +2463,7 @@ public override async Task LongCount_after_GroupBy_aggregate(bool async) """ SELECT COUNT_BIG(*) FROM ( - SELECT [o].[CustomerID] + SELECT 1 AS empty FROM [Orders] AS [o] GROUP BY [o].[CustomerID] ) AS [t] @@ -2590,7 +2590,7 @@ public override async Task Count_after_GroupBy_without_aggregate(bool async) """ SELECT COUNT(*) FROM ( - SELECT [o].[CustomerID] + SELECT 1 AS empty FROM [Orders] AS [o] GROUP BY [o].[CustomerID] ) AS [t] @@ -2605,7 +2605,7 @@ public override async Task Count_with_predicate_after_GroupBy_without_aggregate( """ SELECT COUNT(*) FROM ( - SELECT [o].[CustomerID] + SELECT 1 AS empty FROM [Orders] AS [o] GROUP BY [o].[CustomerID] HAVING COUNT(*) > 1 @@ -2621,7 +2621,7 @@ public override async Task LongCount_after_GroupBy_without_aggregate(bool async) """ SELECT COUNT_BIG(*) FROM ( - SELECT [o].[CustomerID] + SELECT 1 AS empty FROM [Orders] AS [o] GROUP BY [o].[CustomerID] ) AS [t] @@ -2636,7 +2636,7 @@ public override async Task LongCount_with_predicate_after_GroupBy_without_aggreg """ SELECT COUNT_BIG(*) FROM ( - SELECT [o].[CustomerID] + SELECT 1 AS empty FROM [Orders] AS [o] GROUP BY [o].[CustomerID] HAVING COUNT(*) > 1 @@ -2729,7 +2729,7 @@ ELSE CAST(0 AS bit) WHEN ( SELECT COUNT(*) FROM ( - SELECT [p].[ProductName] + SELECT 1 AS empty FROM [Order Details] AS [o1] INNER JOIN [Products] AS [p] ON [o1].[ProductID] = [p].[ProductID] WHERE [o].[OrderID] = [o1].[OrderID] AND [o1].[ProductID] < 25 @@ -2750,7 +2750,7 @@ public override async Task GroupBy_nominal_type_count(bool async) """ SELECT COUNT(*) FROM ( - SELECT [o].[CustomerID] + SELECT 1 AS empty FROM [Orders] AS [o] GROUP BY [o].[CustomerID] ) AS [t] @@ -3570,7 +3570,7 @@ OUTER APPLY ( SELECT COALESCE(SUM([t].[OrderID]), 0) AS [Sum], ( SELECT COUNT(*) FROM ( - SELECT [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate], [c1].[CustomerID] AS [CustomerID0], [c1].[Address], [c1].[City], [c1].[CompanyName], [c1].[ContactName], [c1].[ContactTitle], [c1].[Country], [c1].[Fax], [c1].[Phone], [c1].[PostalCode], [c1].[Region], COALESCE([c1].[City], N'') + COALESCE([o0].[CustomerID], N'') AS [Key] + SELECT [o0].[CustomerID], COALESCE([c1].[City], N'') + COALESCE([o0].[CustomerID], N'') AS [Key] FROM [Orders] AS [o0] LEFT JOIN [Customers] AS [c1] ON [o0].[CustomerID] = [c1].[CustomerID] WHERE [c].[CustomerID] = [o0].[CustomerID] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindJoinQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindJoinQuerySqlServerTest.cs index 074adb38cfa..484aaaac0ac 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindJoinQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindJoinQuerySqlServerTest.cs @@ -202,7 +202,7 @@ public override async Task Join_complex_condition(bool async) SELECT [c].[CustomerID] FROM [Customers] AS [c] CROSS JOIN ( - SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] + SELECT 1 AS empty FROM [Orders] AS [o] WHERE [o].[OrderID] < 10250 ) AS [t] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs index 58af5eb9f92..d447e5a3bba 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs @@ -191,7 +191,7 @@ public override async Task Join_with_entity_equality_local_on_both_sources(bool SELECT [c].[CustomerID] FROM [Customers] AS [c] INNER JOIN ( - SELECT [c0].[CustomerID], [c0].[Address], [c0].[City], [c0].[CompanyName], [c0].[ContactName], [c0].[ContactTitle], [c0].[Country], [c0].[Fax], [c0].[Phone], [c0].[PostalCode], [c0].[Region] + SELECT [c0].[CustomerID] FROM [Customers] AS [c0] WHERE [c0].[CustomerID] = @__entity_equality_local_0_CustomerID ) AS [t] ON [c].[CustomerID] = [t].[CustomerID] @@ -387,7 +387,7 @@ public override async Task Default_if_empty_top_level(bool async) """ SELECT [t].[EmployeeID], [t].[City], [t].[Country], [t].[FirstName], [t].[ReportsTo], [t].[Title] FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e0] LEFT JOIN ( SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] @@ -405,7 +405,7 @@ public override async Task Join_with_default_if_empty_on_both_sources(bool async """ SELECT [t].[EmployeeID], [t].[City], [t].[Country], [t].[FirstName], [t].[ReportsTo], [t].[Title] FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e0] LEFT JOIN ( SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] @@ -413,12 +413,12 @@ FROM [Employees] AS [e] WHERE [e].[EmployeeID] = -1 ) AS [t] ON 1 = 1 INNER JOIN ( - SELECT [t1].[EmployeeID], [t1].[City], [t1].[Country], [t1].[FirstName], [t1].[ReportsTo], [t1].[Title] + SELECT [t1].[EmployeeID] FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e1] LEFT JOIN ( - SELECT [e2].[EmployeeID], [e2].[City], [e2].[Country], [e2].[FirstName], [e2].[ReportsTo], [e2].[Title] + SELECT [e2].[EmployeeID] FROM [Employees] AS [e2] WHERE [e2].[EmployeeID] = -1 ) AS [t1] ON 1 = 1 @@ -434,10 +434,10 @@ public override async Task Default_if_empty_top_level_followed_by_projecting_con """ SELECT N'Foo' FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e0] LEFT JOIN ( - SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] + SELECT 1 AS empty FROM [Employees] AS [e] WHERE [e].[EmployeeID] = -1 ) AS [t] ON 1 = 1 @@ -452,7 +452,7 @@ public override async Task Default_if_empty_top_level_positive(bool async) """ SELECT [t].[EmployeeID], [t].[City], [t].[Country], [t].[FirstName], [t].[ReportsTo], [t].[Title] FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e0] LEFT JOIN ( SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] @@ -470,7 +470,7 @@ public override async Task Default_if_empty_top_level_projection(bool async) """ SELECT COALESCE([t].[EmployeeID], 0) FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e0] LEFT JOIN ( SELECT [e].[EmployeeID] @@ -865,7 +865,7 @@ ORDER BY [o].[OrderID] WHERE ( SELECT COUNT(*) FROM ( - SELECT TOP(2) [o0].[OrderID], [o0].[ProductID], [o0].[Discount], [o0].[Quantity], [o0].[UnitPrice] + SELECT TOP(2) [o0].[OrderID] FROM [Order Details] AS [o0] ORDER BY [o0].[OrderID] ) AS [t0] @@ -1441,7 +1441,7 @@ public override async Task OrderBy_Take_Count(bool async) SELECT COUNT(*) FROM ( - SELECT TOP(@__p_0) [o].[OrderID] + SELECT TOP(@__p_0) 1 AS empty FROM [Orders] AS [o] ORDER BY [o].[OrderID] ) AS [t] @@ -1458,7 +1458,7 @@ public override async Task Take_OrderBy_Count(bool async) SELECT COUNT(*) FROM ( - SELECT TOP(@__p_0) [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] + SELECT TOP(@__p_0) 1 AS empty FROM [Orders] AS [o] ) AS [t] """); @@ -2240,7 +2240,7 @@ SELECT CASE WHEN NOT EXISTS ( SELECT 1 FROM ( - SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] + SELECT [c].[CustomerID] FROM [Customers] AS [c] ORDER BY [c].[CustomerID] OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY @@ -2263,7 +2263,7 @@ SELECT CASE WHEN NOT EXISTS ( SELECT 1 FROM ( - SELECT TOP(@__p_0) [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] + SELECT TOP(@__p_0) [c].[CustomerID] FROM [Customers] AS [c] ORDER BY [c].[CustomerID] ) AS [t] @@ -2286,7 +2286,7 @@ SELECT CASE WHEN EXISTS ( SELECT 1 FROM ( - SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] + SELECT [c].[CustomerID] FROM [Customers] AS [c] ORDER BY [c].[CustomerID] OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY @@ -2309,7 +2309,7 @@ SELECT CASE WHEN EXISTS ( SELECT 1 FROM ( - SELECT TOP(@__p_0) [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] + SELECT TOP(@__p_0) [c].[CustomerID] FROM [Customers] AS [c] ORDER BY [c].[CustomerID] ) AS [t] @@ -3674,7 +3674,7 @@ public override async Task DefaultIfEmpty_without_group_join(bool async) """ SELECT [t].[CustomerID] FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e] LEFT JOIN ( SELECT [c].[CustomerID] @@ -3709,7 +3709,7 @@ FROM [Customers] AS [c] CROSS JOIN ( SELECT [t].[OrderID] FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e] LEFT JOIN ( SELECT [o].[OrderID] @@ -3731,7 +3731,7 @@ FROM [Customers] AS [c] CROSS JOIN ( SELECT [t].[OrderID] FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e] LEFT JOIN ( SELECT [o].[OrderID] @@ -3756,7 +3756,7 @@ FROM [Customers] AS [c] CROSS JOIN ( SELECT [t].[OrderID] FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e] LEFT JOIN ( SELECT [o].[OrderID] @@ -4110,7 +4110,7 @@ FROM [Customers] AS [c1] WHERE EXISTS ( SELECT DISTINCT 1 FROM ( - SELECT TOP(10) [c2].[CustomerID], [c2].[Address], [c2].[City], [c2].[CompanyName], [c2].[ContactName], [c2].[ContactTitle], [c2].[Country], [c2].[Fax], [c2].[Phone], [c2].[PostalCode], [c2].[Region] + SELECT TOP(10) 1 AS empty FROM [Customers] AS [c2] ORDER BY [c2].[CustomerID] ) AS [t]))) @@ -4446,7 +4446,7 @@ public override async Task Select_take_count(bool async) SELECT COUNT(*) FROM ( - SELECT TOP(@__p_0) [c].[CustomerID] + SELECT TOP(@__p_0) 1 AS empty FROM [Customers] AS [c] ) AS [t] """); @@ -4462,7 +4462,7 @@ public override async Task Select_orderBy_take_count(bool async) SELECT COUNT(*) FROM ( - SELECT TOP(@__p_0) [c].[CustomerID] + SELECT TOP(@__p_0) 1 AS empty FROM [Customers] AS [c] ORDER BY [c].[Country] ) AS [t] @@ -4479,7 +4479,7 @@ public override async Task Select_take_long_count(bool async) SELECT COUNT_BIG(*) FROM ( - SELECT TOP(@__p_0) [c].[CustomerID] + SELECT TOP(@__p_0) 1 AS empty FROM [Customers] AS [c] ) AS [t] """); @@ -4495,7 +4495,7 @@ public override async Task Select_orderBy_take_long_count(bool async) SELECT COUNT_BIG(*) FROM ( - SELECT TOP(@__p_0) [c].[CustomerID] + SELECT TOP(@__p_0) 1 AS empty FROM [Customers] AS [c] ORDER BY [c].[Country] ) AS [t] @@ -4581,7 +4581,7 @@ public override async Task Select_skip_count(bool async) SELECT COUNT(*) FROM ( - SELECT [c].[CustomerID] + SELECT 1 AS empty FROM [Customers] AS [c] ORDER BY (SELECT 1) OFFSET @__p_0 ROWS @@ -4599,7 +4599,7 @@ public override async Task Select_orderBy_skip_count(bool async) SELECT COUNT(*) FROM ( - SELECT [c].[CustomerID] + SELECT 1 AS empty FROM [Customers] AS [c] ORDER BY [c].[Country] OFFSET @__p_0 ROWS @@ -4617,7 +4617,7 @@ public override async Task Select_skip_long_count(bool async) SELECT COUNT_BIG(*) FROM ( - SELECT [c].[CustomerID] + SELECT 1 AS empty FROM [Customers] AS [c] ORDER BY (SELECT 1) OFFSET @__p_0 ROWS @@ -4635,7 +4635,7 @@ public override async Task Select_orderBy_skip_long_count(bool async) SELECT COUNT_BIG(*) FROM ( - SELECT [c].[CustomerID] + SELECT 1 AS empty FROM [Customers] AS [c] ORDER BY [c].[Country] OFFSET @__p_0 ROWS @@ -5064,7 +5064,7 @@ public override async Task Join_take_count_works(bool async) SELECT COUNT(*) FROM ( - SELECT TOP(@__p_0) [o].[OrderID], [t].[CustomerID] + SELECT TOP(@__p_0) 1 AS empty FROM [Orders] AS [o] INNER JOIN ( SELECT [c].[CustomerID] @@ -5315,10 +5315,10 @@ SELECT CASE WHEN EXISTS ( SELECT 1 FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e0] LEFT JOIN ( - SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] + SELECT 1 AS empty FROM [Employees] AS [e] WHERE [e].[EmployeeID] = -1 ) AS [t] ON 1 = 1) THEN CAST(1 AS bit) @@ -5845,10 +5845,10 @@ public override async Task DefaultIfEmpty_Sum_over_collection_navigation(bool as SELECT [c].[CustomerID], ( SELECT COALESCE(SUM(COALESCE([t].[OrderID], 0)), 0) FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e] LEFT JOIN ( - SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] + SELECT [o].[OrderID] FROM [Orders] AS [o] WHERE [c].[CustomerID] = [o].[CustomerID] ) AS [t] ON 1 = 1) AS [Sum] @@ -5888,10 +5888,10 @@ public override async Task DefaultIfEmpty_over_empty_collection_followed_by_proj """ SELECT TOP(1) N'520' FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e] LEFT JOIN ( - SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] + SELECT 1 AS empty FROM [Customers] AS [c] WHERE 0 = 1 ) AS [t] ON 1 = 1 @@ -5958,7 +5958,7 @@ FROM [Employees] AS [e] WHERE [t0].[City] = [e].[City] OR ([t0].[City] IS NULL AND [e].[City] IS NULL) ) AS [t1] CROSS APPLY ( - SELECT TOP(9) [t0].[City], [e0].[EmployeeID] + SELECT TOP(9) 1 AS empty FROM [Employees] AS [e0] WHERE [t1].[City] = [e0].[City] OR ([t1].[City] IS NULL AND [e0].[City] IS NULL) ) AS [t2] @@ -6827,7 +6827,7 @@ public override async Task Collection_projection_after_DefaultIfEmpty(bool async """ SELECT [t].[CustomerID], [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM ( - SELECT NULL AS [empty] + SELECT 1 AS empty ) AS [e] LEFT JOIN ( SELECT [c].[CustomerID] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs index cb30eed1721..6b41b2c59cf 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs @@ -1015,7 +1015,7 @@ public override async Task GroupJoin_with_complex_subquery_and_LOJ_gets_flattene 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] LEFT JOIN ( - SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice], [o0].[OrderID] AS [OrderID0], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate], [c0].[CustomerID] AS [CustomerID0], [c0].[Address], [c0].[City], [c0].[CompanyName], [c0].[ContactName], [c0].[ContactTitle], [c0].[Country], [c0].[Fax], [c0].[Phone], [c0].[PostalCode], [c0].[Region] + SELECT [c0].[CustomerID] AS [CustomerID0] FROM [Order Details] AS [o] INNER JOIN [Orders] AS [o0] ON [o].[OrderID] = 10260 INNER JOIN [Customers] AS [c0] ON [o0].[CustomerID] = [c0].[CustomerID] @@ -1032,7 +1032,7 @@ public override async Task GroupJoin_with_complex_subquery_and_LOJ_gets_flattene SELECT [c].[CustomerID] FROM [Customers] AS [c] LEFT JOIN ( - SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice], [o0].[OrderID] AS [OrderID0], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate], [c0].[CustomerID] AS [CustomerID0], [c0].[Address], [c0].[City], [c0].[CompanyName], [c0].[ContactName], [c0].[ContactTitle], [c0].[Country], [c0].[Fax], [c0].[Phone], [c0].[PostalCode], [c0].[Region] + SELECT [c0].[CustomerID] AS [CustomerID0] FROM [Order Details] AS [o] INNER JOIN [Orders] AS [o0] ON [o].[OrderID] = 10260 INNER JOIN [Customers] AS [c0] ON [o0].[CustomerID] = [c0].[CustomerID] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryTaggingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryTaggingQuerySqlServerTest.cs index c2be0b200fb..13d36bc243f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryTaggingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryTaggingQuerySqlServerTest.cs @@ -62,7 +62,7 @@ public override void Tags_on_subquery() 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] CROSS JOIN ( - SELECT TOP(5) [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] + SELECT TOP(5) 1 AS empty FROM [Orders] AS [o] ORDER BY [o].[OrderID] ) AS [t] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs index ea1644063ca..23446b3fed9 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs @@ -861,7 +861,7 @@ public override async Task Project_single_element_from_collection_with_multiple_ SELECT ( SELECT TOP(1) [t].[CustomerID] FROM ( - SELECT TOP(2) [o].[CustomerID], [o].[OrderID], [o].[OrderDate] + SELECT TOP(2) [o].[CustomerID], [o].[OrderDate] FROM [Orders] AS [o] WHERE [c].[CustomerID] = [o].[CustomerID] ORDER BY [o].[CustomerID], [o].[OrderDate] DESC @@ -880,7 +880,7 @@ public override async Task Project_single_element_from_collection_with_OrderBy_o SELECT COALESCE(( SELECT TOP(1) [t].[OrderID] FROM ( - SELECT TOP(1) [o0].[OrderID], [o0].[ProductID], [p].[ProductID] AS [ProductID0], [p].[ProductName] + SELECT TOP(1) [o0].[OrderID], [p].[ProductName] FROM [Order Details] AS [o0] INNER JOIN [Products] AS [p] ON [o0].[ProductID] = [p].[ProductID] WHERE [o].[OrderID] = [o0].[OrderID] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs index b5368c88c83..5c87cdf29d5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs @@ -1287,7 +1287,7 @@ public override async Task GroupBy_with_multiple_aggregates_on_owned_navigation_ SELECT ( SELECT AVG(CAST([s].[Id] AS float)) FROM ( - SELECT [o0].[Id], [o0].[Discriminator], [o0].[Name], 1 AS [Key], [o0].[PersonAddress_AddressLine], [o0].[PersonAddress_PlaceType], [o0].[PersonAddress_ZipCode], [o0].[PersonAddress_Country_Name], [o0].[PersonAddress_Country_PlanetId] + SELECT 1 AS [Key], [o0].[PersonAddress_Country_PlanetId] FROM [OwnedPerson] AS [o0] ) AS [t0] LEFT JOIN [Planet] AS [p] ON [t0].[PersonAddress_Country_PlanetId] = [p].[Id] @@ -1295,7 +1295,7 @@ FROM [OwnedPerson] AS [o0] WHERE [t].[Key] = [t0].[Key]) AS [p1], ( SELECT COALESCE(SUM([s0].[Id]), 0) FROM ( - SELECT [o1].[Id], [o1].[Discriminator], [o1].[Name], 1 AS [Key], [o1].[PersonAddress_AddressLine], [o1].[PersonAddress_PlaceType], [o1].[PersonAddress_ZipCode], [o1].[PersonAddress_Country_Name], [o1].[PersonAddress_Country_PlanetId] + SELECT 1 AS [Key], [o1].[PersonAddress_Country_PlanetId] FROM [OwnedPerson] AS [o1] ) AS [t1] LEFT JOIN [Planet] AS [p0] ON [t1].[PersonAddress_Country_PlanetId] = [p0].[Id] @@ -1303,7 +1303,7 @@ FROM [OwnedPerson] AS [o1] WHERE [t].[Key] = [t1].[Key]) AS [p2], ( SELECT MAX(CAST(LEN([s1].[Name]) AS int)) FROM ( - SELECT [o2].[Id], [o2].[Discriminator], [o2].[Name], 1 AS [Key], [o2].[PersonAddress_AddressLine], [o2].[PersonAddress_PlaceType], [o2].[PersonAddress_ZipCode], [o2].[PersonAddress_Country_Name], [o2].[PersonAddress_Country_PlanetId] + SELECT 1 AS [Key], [o2].[PersonAddress_Country_PlanetId] FROM [OwnedPerson] AS [o2] ) AS [t2] LEFT JOIN [Planet] AS [p1] ON [t2].[PersonAddress_Country_PlanetId] = [p1].[Id] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerTest.cs index 742e3f8c909..fca37e13ab5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerTest.cs @@ -723,7 +723,7 @@ FROM [PrimitiveCollectionsEntity] AS [p] WHERE ( SELECT COUNT(*) FROM ( - SELECT [i].[key] + SELECT 1 AS empty FROM OPENJSON([p].[Ints]) AS [i] ORDER BY CAST([i].[key] AS int) OFFSET 1 ROWS @@ -880,10 +880,10 @@ FROM [PrimitiveCollectionsEntity] AS [p] WHERE ( SELECT COUNT(*) FROM ( - SELECT [i].[value] + SELECT 1 AS empty FROM OPENJSON(@__ints_0) WITH ([value] int '$') AS [i] UNION ALL - SELECT [i0].[value] + SELECT 1 AS empty FROM OPENJSON([p].[Ints]) WITH ([value] int '$') AS [i0] ) AS [t]) = 2 """); @@ -1007,7 +1007,7 @@ SELECT COUNT(*) FROM ( SELECT [t].[value] FROM ( - SELECT CAST([i].[value] AS int) AS [value], [i].[key] + SELECT CAST([i].[value] AS int) AS [value] FROM OPENJSON(@__ints) AS [i] ORDER BY CAST([i].[key] AS int) OFFSET 1 ROWS @@ -1063,9 +1063,9 @@ SELECT TOP(20) [t0].[value] FROM ( SELECT DISTINCT [t2].[value] FROM ( - SELECT CAST([i].[value] AS int) AS [value], [i].[key] - FROM OPENJSON([p].[Ints]) AS [i] - ORDER BY CAST([i].[value] AS int) + SELECT [i].[value] + FROM OPENJSON([p].[Ints]) WITH ([value] int '$') AS [i] + ORDER BY [i].[value] OFFSET 1 ROWS ) AS [t2] ) AS [t0] @@ -1096,7 +1096,7 @@ FROM [PrimitiveCollectionsEntity] AS [p] WHERE ( SELECT COUNT(*) FROM ( - SELECT CAST([i].[value] AS int) AS [value], [i].[key], CAST([i].[key] AS int) AS [c], CAST([i].[value] AS int) AS [value0] + SELECT CAST([i].[value] AS int) AS [value0] FROM OPENJSON(@__ints) AS [i] ORDER BY CAST([i].[key] AS int) OFFSET 1 ROWS @@ -1127,7 +1127,7 @@ SELECT COUNT(*) FROM ( SELECT [t].[value] FROM ( - SELECT CAST([i].[value] AS int) AS [value], [i].[key] + SELECT CAST([i].[value] AS int) AS [value] FROM OPENJSON([p].[Ints]) AS [i] ORDER BY CAST([i].[key] AS int) OFFSET 1 ROWS diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs index 36f0a8b5be2..794ddc23317 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs @@ -838,19 +838,19 @@ FROM [Officers] AS [o] WHERE [t].[Rank] & COALESCE(( SELECT TOP(1) [t0].[Rank] FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] FROM [Officers] AS [o0] ) AS [t0] ORDER BY [t0].[Nickname], [t0].[SquadId]), 0) = COALESCE(( SELECT TOP(1) [t0].[Rank] FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] FROM [Officers] AS [o0] ) AS [t0] ORDER BY [t0].[Nickname], [t0].[SquadId]), 0) @@ -868,19 +868,19 @@ FROM [Officers] AS [o] WHERE 2 & COALESCE(( SELECT TOP(1) [t0].[Rank] FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] FROM [Officers] AS [o0] ) AS [t0] ORDER BY [t0].[Nickname], [t0].[SquadId]), 0) = COALESCE(( SELECT TOP(1) [t0].[Rank] FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] FROM [Officers] AS [o0] ) AS [t0] ORDER BY [t0].[Nickname], [t0].[SquadId]), 0) @@ -904,28 +904,28 @@ FROM [Officers] AS [o] WHERE [t].[Rank] & ( SELECT TOP(1) [t0].[Rank] FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] FROM [Officers] AS [o0] ) AS [t0] ORDER BY [t0].[Nickname], [t0].[SquadId]) = ( SELECT TOP(1) [t0].[Rank] FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] FROM [Officers] AS [o0] ) AS [t0] ORDER BY [t0].[Nickname], [t0].[SquadId]) OR ( SELECT TOP(1) [t0].[Rank] FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] FROM [Officers] AS [o0] ) AS [t0] ORDER BY [t0].[Nickname], [t0].[SquadId]) IS NULL @@ -943,28 +943,28 @@ FROM [Officers] AS [o] WHERE 2 & ( SELECT TOP(1) [t0].[Rank] FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] FROM [Officers] AS [o0] ) AS [t0] ORDER BY [t0].[Nickname], [t0].[SquadId]) = ( SELECT TOP(1) [t0].[Rank] FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] FROM [Officers] AS [o0] ) AS [t0] ORDER BY [t0].[Nickname], [t0].[SquadId]) OR ( SELECT TOP(1) [t0].[Rank] FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] FROM [Officers] AS [o0] ) AS [t0] ORDER BY [t0].[Nickname], [t0].[SquadId]) IS NULL @@ -988,28 +988,28 @@ FROM [Officers] AS [o] WHERE [t].[Rank] & ( SELECT TOP(1) [t0].[Rank] FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] FROM [Officers] AS [o0] ) AS [t0] ORDER BY [t0].[Nickname], [t0].[SquadId]) = ( SELECT TOP(1) [t0].[Rank] FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] FROM [Officers] AS [o0] ) AS [t0] ORDER BY [t0].[Nickname], [t0].[SquadId]) OR ( SELECT TOP(1) [t0].[Rank] FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] FROM [Officers] AS [o0] ) AS [t0] ORDER BY [t0].[Nickname], [t0].[SquadId]) IS NULL @@ -2437,7 +2437,7 @@ FROM [Officers] AS [o] SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] INNER JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + SELECT [w0].[Id] FROM [Weapons] AS [w0] WHERE [t].[FullName] = [w0].[OwnerFullName] ) AS [t0] ON [w].[Id] = [t0].[Id] @@ -2464,7 +2464,7 @@ FROM [Officers] AS [o] SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + SELECT [w0].[Id] FROM [Weapons] AS [w0] WHERE [t].[FullName] = [w0].[OwnerFullName] ) AS [t0] ON [w].[Id] = [t0].[Id] @@ -2490,11 +2490,11 @@ FROM [Officers] AS [o] WHERE [t].[HasSoulPatch] = CAST(1 AS bit) AND ( SELECT TOP(1) [t0].[IsAutomatic] FROM ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + SELECT [w].[Id], [w].[IsAutomatic] FROM [Weapons] AS [w] WHERE [t].[FullName] = [w].[OwnerFullName] UNION ALL - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + SELECT [w0].[Id], [w0].[IsAutomatic] FROM [Weapons] AS [w0] WHERE [t].[FullName] = [w0].[OwnerFullName] ) AS [t0] @@ -2510,16 +2510,16 @@ public override async Task Concat_with_count(bool async) """ SELECT COUNT(*) FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT 1 AS empty FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT 1 AS empty FROM [Officers] AS [o] UNION ALL - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT 1 AS empty FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT 1 AS empty FROM [Officers] AS [o0] ) AS [t0] """); @@ -2533,16 +2533,16 @@ public override async Task Concat_scalars_with_count(bool async) """ SELECT COUNT(*) FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT 1 AS empty FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT 1 AS empty FROM [Officers] AS [o] UNION ALL - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT 1 AS empty FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT 1 AS empty FROM [Officers] AS [o0] ) AS [t0] """); @@ -2556,21 +2556,21 @@ public override async Task Concat_anonymous_with_count(bool async) """ SELECT COUNT(*) FROM ( - SELECT [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOfBirthName], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank], [t].[Discriminator], [t].[Nickname] AS [Name] + SELECT 1 AS empty FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT 1 AS empty FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT 1 AS empty FROM [Officers] AS [o] ) AS [t] UNION ALL - SELECT [t1].[Nickname], [t1].[SquadId], [t1].[AssignedCityName], [t1].[CityOfBirthName], [t1].[FullName], [t1].[HasSoulPatch], [t1].[LeaderNickname], [t1].[LeaderSquadId], [t1].[Rank], [t1].[Discriminator], [t1].[FullName] AS [Name] + SELECT 1 AS empty FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT 1 AS empty FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT 1 AS empty FROM [Officers] AS [o0] ) AS [t1] ) AS [t0] @@ -2606,11 +2606,11 @@ public override async Task Select_navigation_with_concat_and_count(bool async) SELECT ( SELECT COUNT(*) FROM ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + SELECT 1 AS empty FROM [Weapons] AS [w] WHERE [t].[FullName] = [w].[OwnerFullName] UNION ALL - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + SELECT 1 AS empty FROM [Weapons] AS [w0] WHERE [t].[FullName] = [w0].[OwnerFullName] ) AS [t0]) @@ -2942,10 +2942,10 @@ FROM [Cities] AS [c] WHERE [c].[Location] = 'Unknown' AND ( SELECT COUNT(*) FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[CityOfBirthName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[Nickname], [o].[CityOfBirthName] FROM [Officers] AS [o] ) AS [t] WHERE [c].[Name] = [t].[CityOfBirthName] AND [t].[Nickname] = N'Paduk') = 1 @@ -3525,10 +3525,10 @@ WHEN NOT EXISTS ( SELECT 1 FROM [Tags] AS [t] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [t0] ON [t].[GearNickName] = [t0].[Nickname] AND [t].[GearSquadId] = [t0].[SquadId] WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [t0].[HasSoulPatch] = CAST(0 AS bit)) THEN CAST(1 AS bit) @@ -4078,10 +4078,10 @@ public override async Task FirstOrDefault_with_manually_created_groupjoin_is_tra SELECT TOP(1) [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[SquadId] FROM [Officers] AS [o] ) AS [t] ON [s].[Id] = [t].[SquadId] WHERE [s].[Name] = N'Kilo' @@ -4099,10 +4099,10 @@ FROM [Squads] AS [s] WHERE NOT EXISTS ( SELECT 1 FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] ) AS [t] LEFT JOIN [Tags] AS [t0] ON [t].[Nickname] = [t0].[GearNickName] AND [t].[SquadId] = [t0].[GearSquadId] @@ -4120,10 +4120,10 @@ SELECT CASE WHEN NOT EXISTS ( SELECT 1 FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] ) AS [t] LEFT JOIN [Tags] AS [t0] ON [t].[Nickname] = [t0].[GearNickName] AND [t].[SquadId] = [t0].[GearSquadId] @@ -4631,10 +4631,10 @@ public override async Task Collection_navigation_access_on_derived_entity_using_ SELECT [l].[Name], ( SELECT COUNT(*) FROM ( - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + SELECT [l0].[LocustHordeId] FROM [LocustLeaders] AS [l0] UNION ALL - SELECT [l1].[Name], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId], N'LocustCommander' AS [Discriminator] + SELECT [l1].[LocustHordeId] FROM [LocustCommanders] AS [l1] ) AS [t] WHERE [l].[Id] = [t].[LocustHordeId]) AS [LeadersCount] @@ -4828,10 +4828,10 @@ FROM [Officers] AS [o] WHERE [t0].[Discriminator] = N'Officer' AND ( SELECT COUNT(*) FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[LeaderNickname], [g0].[LeaderSquadId] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[Nickname], [o0].[LeaderNickname], [o0].[LeaderSquadId] FROM [Officers] AS [o0] ) AS [t1] WHERE [t0].[Nickname] IS NOT NULL AND [t0].[SquadId] IS NOT NULL AND [t0].[Nickname] = [t1].[LeaderNickname] AND [t0].[SquadId] = [t1].[LeaderSquadId] AND [t1].[Nickname] = N'Dom') > 0 @@ -5900,10 +5900,10 @@ FROM [Officers] AS [o] WHERE EXISTS ( SELECT 1 FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[LeaderNickname], [g].[LeaderSquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[LeaderNickname], [o0].[LeaderSquadId] FROM [Officers] AS [o0] ) AS [t1] WHERE [t].[Nickname] = [t1].[LeaderNickname] AND [t].[SquadId] = [t1].[LeaderSquadId]) @@ -5944,10 +5944,10 @@ FROM [Officers] AS [o1] WHERE EXISTS ( SELECT 1 FROM ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank], N'Gear' AS [Discriminator] + SELECT [g1].[LeaderNickname], [g1].[LeaderSquadId] FROM [Gears] AS [g1] UNION ALL - SELECT [o2].[Nickname], [o2].[SquadId], [o2].[AssignedCityName], [o2].[CityOfBirthName], [o2].[FullName], [o2].[HasSoulPatch], [o2].[LeaderNickname], [o2].[LeaderSquadId], [o2].[Rank], N'Officer' AS [Discriminator] + SELECT [o2].[LeaderNickname], [o2].[LeaderSquadId] FROM [Officers] AS [o2] ) AS [t1] WHERE [t].[Nickname] = [t1].[LeaderNickname] AND [t].[SquadId] = [t1].[LeaderSquadId]) @@ -5989,10 +5989,10 @@ FROM [Officers] AS [o1] WHERE EXISTS ( SELECT 1 FROM ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank], N'Gear' AS [Discriminator] + SELECT [g1].[LeaderNickname], [g1].[LeaderSquadId] FROM [Gears] AS [g1] UNION ALL - SELECT [o2].[Nickname], [o2].[SquadId], [o2].[AssignedCityName], [o2].[CityOfBirthName], [o2].[FullName], [o2].[HasSoulPatch], [o2].[LeaderNickname], [o2].[LeaderSquadId], [o2].[Rank], N'Officer' AS [Discriminator] + SELECT [o2].[LeaderNickname], [o2].[LeaderSquadId] FROM [Officers] AS [o2] ) AS [t1] WHERE [t].[Nickname] = [t1].[LeaderNickname] AND [t].[SquadId] = [t1].[LeaderSquadId]) @@ -6037,10 +6037,10 @@ FROM [Officers] AS [o1] WHERE EXISTS ( SELECT 1 FROM ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank], N'Gear' AS [Discriminator] + SELECT [g1].[LeaderNickname], [g1].[LeaderSquadId] FROM [Gears] AS [g1] UNION ALL - SELECT [o2].[Nickname], [o2].[SquadId], [o2].[AssignedCityName], [o2].[CityOfBirthName], [o2].[FullName], [o2].[HasSoulPatch], [o2].[LeaderNickname], [o2].[LeaderSquadId], [o2].[Rank], N'Officer' AS [Discriminator] + SELECT [o2].[LeaderNickname], [o2].[LeaderSquadId] FROM [Officers] AS [o2] ) AS [t1] WHERE [t].[Nickname] = [t1].[LeaderNickname] AND [t].[SquadId] = [t1].[LeaderSquadId]) @@ -6113,10 +6113,10 @@ FROM [Officers] AS [o4] WHERE EXISTS ( SELECT 1 FROM ( - SELECT [g4].[Nickname], [g4].[SquadId], [g4].[AssignedCityName], [g4].[CityOfBirthName], [g4].[FullName], [g4].[HasSoulPatch], [g4].[LeaderNickname], [g4].[LeaderSquadId], [g4].[Rank], N'Gear' AS [Discriminator] + SELECT [g4].[LeaderNickname], [g4].[LeaderSquadId] FROM [Gears] AS [g4] UNION ALL - SELECT [o5].[Nickname], [o5].[SquadId], [o5].[AssignedCityName], [o5].[CityOfBirthName], [o5].[FullName], [o5].[HasSoulPatch], [o5].[LeaderNickname], [o5].[LeaderSquadId], [o5].[Rank], N'Officer' AS [Discriminator] + SELECT [o5].[LeaderNickname], [o5].[LeaderSquadId] FROM [Officers] AS [o5] ) AS [t1] WHERE [t].[Nickname] = [t1].[LeaderNickname] AND [t].[SquadId] = [t1].[LeaderSquadId]) @@ -6363,10 +6363,10 @@ public override async Task Correlated_collections_with_FirstOrDefault(bool async SELECT ( SELECT TOP(1) [t].[FullName] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] ) AS [t] WHERE [s].[Id] = [t].[SquadId] @@ -6704,10 +6704,10 @@ public override async Task Correlated_collection_with_top_level_Count(bool async """ SELECT COUNT(*) FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT 1 AS empty FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT 1 AS empty FROM [Officers] AS [o] ) AS [t] """); @@ -7273,10 +7273,10 @@ public override async Task Project_one_value_type_from_empty_collection(bool asy SELECT [s].[Name], COALESCE(( SELECT TOP(1) [t].[SquadId] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [t] WHERE [s].[Id] = [t].[SquadId] AND [t].[HasSoulPatch] = CAST(1 AS bit)), 0) AS [SquadId] @@ -7294,10 +7294,10 @@ public override async Task Project_one_value_type_converted_to_nullable_from_emp SELECT [s].[Name], ( SELECT TOP(1) [t].[SquadId] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [t] WHERE [s].[Id] = [t].[SquadId] AND [t].[HasSoulPatch] = CAST(1 AS bit)) AS [SquadId] @@ -7344,10 +7344,10 @@ FROM [Squads] AS [s] WHERE [s].[Name] = N'Kilo' AND COALESCE(( SELECT TOP(1) [t].[SquadId] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [t] WHERE [s].[Id] = [t].[SquadId] AND [t].[HasSoulPatch] = CAST(1 AS bit)), 0) <> 0 @@ -7363,10 +7363,10 @@ public override async Task Select_subquery_projecting_single_constant_int(bool a SELECT [s].[Name], COALESCE(( SELECT TOP(1) 42 FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [t] WHERE [s].[Id] = [t].[SquadId] AND [t].[HasSoulPatch] = CAST(1 AS bit)), 0) AS [Gear] @@ -7383,10 +7383,10 @@ public override async Task Select_subquery_projecting_single_constant_string(boo SELECT [s].[Name], ( SELECT TOP(1) N'Foo' FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [t] WHERE [s].[Id] = [t].[SquadId] AND [t].[HasSoulPatch] = CAST(1 AS bit)) AS [Gear] @@ -7403,10 +7403,10 @@ public override async Task Select_subquery_projecting_single_constant_bool(bool SELECT [s].[Name], COALESCE(( SELECT TOP(1) CAST(1 AS bit) FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [t] WHERE [s].[Id] = [t].[SquadId] AND [t].[HasSoulPatch] = CAST(1 AS bit)), CAST(0 AS bit)) AS [Gear] @@ -7690,10 +7690,10 @@ FROM [Weapons] AS [w] WHERE [t].[FullName] = [w].[OwnerFullName] AND [w].[IsAutomatic] = COALESCE(( SELECT TOP(1) [t0].[HasSoulPatch] FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[HasSoulPatch] FROM [Gears] AS [g0] UNION ALL - SELECT [o1].[Nickname], [o1].[SquadId], [o1].[AssignedCityName], [o1].[CityOfBirthName], [o1].[FullName], [o1].[HasSoulPatch], [o1].[LeaderNickname], [o1].[LeaderSquadId], [o1].[Rank], N'Officer' AS [Discriminator] + SELECT [o1].[Nickname], [o1].[HasSoulPatch] FROM [Officers] AS [o1] ) AS [t0] WHERE [t0].[Nickname] = N'Marcus'), CAST(0 AS bit))), [t].[Nickname], [t].[SquadId], [t1].[Nickname] @@ -8863,10 +8863,10 @@ FROM [Cities] AS [c] WHERE EXISTS ( SELECT 1 FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[CityOfBirthName] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[CityOfBirthName] FROM [Officers] AS [o0] ) AS [t0] WHERE [c].[Name] = [t0].[CityOfBirthName] AND [t0].[Nickname] = [t].[Nickname] AND [t0].[SquadId] = [t].[SquadId])) @@ -8936,10 +8936,10 @@ FROM [Cities] AS [c] WHERE ( SELECT TOP(1) [t].[HasSoulPatch] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [t] ORDER BY [t].[Nickname], [t].[SquadId]) = CAST(1 AS bit) @@ -9156,10 +9156,10 @@ UNION ALL FROM [Officers] AS [o] ) AS [t] INNER JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[Nickname] FROM [Officers] AS [o0] ) AS [t0] ON [t].[Nickname] = [t0].[Nickname] """); @@ -9180,10 +9180,10 @@ UNION ALL FROM [Officers] AS [o] ) AS [t] INNER JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[Nickname] FROM [Officers] AS [o0] ) AS [t0] ON [t].[Nickname] = [t0].[Nickname] """); @@ -9426,7 +9426,7 @@ FROM [Cities] AS [c] WHERE EXISTS ( SELECT 1 FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[Nickname], [o].[CityOfBirthName] FROM [Officers] AS [o] ) AS [t] WHERE [c].[Name] = [t].[CityOfBirthName] AND [t].[Nickname] = N'Marcus') @@ -9514,10 +9514,10 @@ FROM [Squads] AS [s] WHERE EXISTS ( SELECT 1 FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[SquadId] FROM [Officers] AS [o] ) AS [t] WHERE [s].[Id] = [t].[SquadId] AND [t].[SquadId] = @__gearId_0 AND [t].[SquadId] = @__gearId_0) @@ -9777,10 +9777,10 @@ public override async Task Select_null_parameter_is_not_null(bool async) SELECT @__p_0 FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT 1 AS empty FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT 1 AS empty FROM [Officers] AS [o] ) AS [t] """); @@ -9925,20 +9925,20 @@ FROM [Officers] AS [o] WHERE [c].[Name] = ( SELECT TOP(1) [c0].[Name] FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[CityOfBirthName] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[Nickname], [o0].[CityOfBirthName] FROM [Officers] AS [o0] ) AS [t0] INNER JOIN [Cities] AS [c0] ON [t0].[CityOfBirthName] = [c0].[Name] ORDER BY [t0].[Nickname]) OR ([c].[Name] IS NULL AND ( SELECT TOP(1) [c0].[Name] FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[CityOfBirthName] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[Nickname], [o0].[CityOfBirthName] FROM [Officers] AS [o0] ) AS [t0] INNER JOIN [Cities] AS [c0] ON [t0].[CityOfBirthName] = [c0].[Name] @@ -11095,10 +11095,10 @@ FROM [Squads] AS [s] WHERE [s].[Name] = N'Delta' AND COALESCE(( SELECT TOP(1) [t].[SquadId] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[SquadId], [g].[FullName], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[SquadId], [o].[FullName], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [t] WHERE [s].[Id] = [t].[SquadId] AND [t].[HasSoulPatch] = CAST(1 AS bit) @@ -12986,10 +12986,10 @@ FROM [Squads] AS [s] WHERE NOT EXISTS ( SELECT 1 FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[SquadId] FROM [Officers] AS [o] ) AS [t] WHERE [s].[Id] = [t].[SquadId]) @@ -13007,10 +13007,10 @@ FROM [Squads] AS [s] WHERE NOT EXISTS ( SELECT 1 FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] ) AS [t] WHERE [s].[Id] = [t].[SquadId] AND [t].[FullName] = N'Anthony Carmine') @@ -13204,10 +13204,10 @@ FROM [Squads] AS [s] WHERE NOT EXISTS ( SELECT 1 FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] ) AS [t] WHERE [s].[Id] = [t].[SquadId] @@ -13227,10 +13227,10 @@ FROM [Squads] AS [s] WHERE ( SELECT [t].[Nickname] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] ) AS [t] WHERE [s].[Id] = [t].[SquadId] @@ -13313,29 +13313,26 @@ public override async Task Set_operator_with_navigation_in_projection_groupby_ag SELECT [s].[Name], ( SELECT COALESCE(SUM(CAST(LEN([c].[Location]) AS int)), 0) FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[SquadId], [g0].[CityOfBirthName] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[SquadId], [o0].[CityOfBirthName] FROM [Officers] AS [o0] ) AS [t3] INNER JOIN [Squads] AS [s0] ON [t3].[SquadId] = [s0].[Id] INNER JOIN [Cities] AS [c] ON [t3].[CityOfBirthName] = [c].[Name] WHERE N'Marcus' IN ( - SELECT [t4].[Nickname] - FROM ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g1] - UNION ALL - SELECT [o1].[Nickname], [o1].[SquadId], [o1].[AssignedCityName], [o1].[CityOfBirthName], [o1].[FullName], [o1].[HasSoulPatch], [o1].[LeaderNickname], [o1].[LeaderSquadId], [o1].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o1] - UNION ALL - SELECT [g2].[Nickname], [g2].[SquadId], [g2].[AssignedCityName], [g2].[CityOfBirthName], [g2].[FullName], [g2].[HasSoulPatch], [g2].[LeaderNickname], [g2].[LeaderSquadId], [g2].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g2] - UNION ALL - SELECT [o2].[Nickname], [o2].[SquadId], [o2].[AssignedCityName], [o2].[CityOfBirthName], [o2].[FullName], [o2].[HasSoulPatch], [o2].[LeaderNickname], [o2].[LeaderSquadId], [o2].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o2] - ) AS [t4] + SELECT [g1].[Nickname] + FROM [Gears] AS [g1] + UNION ALL + SELECT [o1].[Nickname] + FROM [Officers] AS [o1] + UNION ALL + SELECT [g2].[Nickname] + FROM [Gears] AS [g2] + UNION ALL + SELECT [o2].[Nickname] + FROM [Officers] AS [o2] ) AND ([s].[Name] = [s0].[Name] OR ([s].[Name] IS NULL AND [s0].[Name] IS NULL))) AS [SumOfLengths] FROM ( SELECT [g].[SquadId] @@ -13346,20 +13343,17 @@ FROM [Officers] AS [o] ) AS [t] INNER JOIN [Squads] AS [s] ON [t].[SquadId] = [s].[Id] WHERE N'Marcus' IN ( - SELECT [t0].[Nickname] - FROM ( - SELECT [g3].[Nickname], [g3].[SquadId], [g3].[AssignedCityName], [g3].[CityOfBirthName], [g3].[FullName], [g3].[HasSoulPatch], [g3].[LeaderNickname], [g3].[LeaderSquadId], [g3].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g3] - UNION ALL - SELECT [o3].[Nickname], [o3].[SquadId], [o3].[AssignedCityName], [o3].[CityOfBirthName], [o3].[FullName], [o3].[HasSoulPatch], [o3].[LeaderNickname], [o3].[LeaderSquadId], [o3].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o3] - UNION ALL - SELECT [g4].[Nickname], [g4].[SquadId], [g4].[AssignedCityName], [g4].[CityOfBirthName], [g4].[FullName], [g4].[HasSoulPatch], [g4].[LeaderNickname], [g4].[LeaderSquadId], [g4].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g4] - UNION ALL - SELECT [o4].[Nickname], [o4].[SquadId], [o4].[AssignedCityName], [o4].[CityOfBirthName], [o4].[FullName], [o4].[HasSoulPatch], [o4].[LeaderNickname], [o4].[LeaderSquadId], [o4].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o4] - ) AS [t0] + SELECT [g3].[Nickname] + FROM [Gears] AS [g3] + UNION ALL + SELECT [o3].[Nickname] + FROM [Officers] AS [o3] + UNION ALL + SELECT [g4].[Nickname] + FROM [Gears] AS [g4] + UNION ALL + SELECT [o4].[Nickname] + FROM [Officers] AS [o4] ) GROUP BY [s].[Name] """); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPCInheritanceQuerySqlServerTestBase.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPCInheritanceQuerySqlServerTestBase.cs index afedeca63c8..d8766f7720e 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPCInheritanceQuerySqlServerTestBase.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPCInheritanceQuerySqlServerTestBase.cs @@ -535,12 +535,12 @@ FROM [Kiwi] AS [k] WHERE EXISTS ( SELECT 1 FROM ( - SELECT TOP(1) [t1].[Id], [t1].[CountryId], [t1].[Name], [t1].[Species], [t1].[EagleId], [t1].[IsFlightless], [t1].[Group], [t1].[FoundOn], [t1].[Discriminator] + SELECT TOP(1) [t1].[Discriminator] FROM ( - SELECT [e0].[Id], [e0].[CountryId], [e0].[Name], [e0].[Species], [e0].[EagleId], [e0].[IsFlightless], [e0].[Group], NULL AS [FoundOn], N'Eagle' AS [Discriminator] + SELECT [e0].[Name], N'Eagle' AS [Discriminator] FROM [Eagle] AS [e0] UNION ALL - SELECT [k0].[Id], [k0].[CountryId], [k0].[Name], [k0].[Species], [k0].[EagleId], [k0].[IsFlightless], NULL AS [Group], [k0].[FoundOn], N'Kiwi' AS [Discriminator] + SELECT [k0].[Name], N'Kiwi' AS [Discriminator] FROM [Kiwi] AS [k0] ) AS [t1] WHERE [t1].[Name] = N'Great spotted kiwi' diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPCManyToManyNoTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPCManyToManyNoTrackingQuerySqlServerTest.cs index 3a6eebb3ce9..80b38b3ad9b 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPCManyToManyNoTrackingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPCManyToManyNoTrackingQuerySqlServerTest.cs @@ -111,10 +111,10 @@ ORDER BY ( SELECT COUNT(*) FROM [JoinOneToBranch] AS [j] INNER JOIN ( - SELECT [b].[Id], [b].[Name], [b].[Number], NULL AS [IsGreen], N'EntityBranch' AS [Discriminator] + SELECT [b].[Id], [b].[Name] FROM [Branches] AS [b] UNION ALL - SELECT [l].[Id], [l].[Name], [l].[Number], [l].[IsGreen], N'EntityLeaf' AS [Discriminator] + SELECT [l].[Id], [l].[Name] FROM [Leaves] AS [l] ) AS [t] ON [j].[EntityBranchId] = [t].[Id] WHERE [e].[Id] = [j].[EntityOneId] AND [t].[Name] LIKE N'L%'), [e].[Id] @@ -2199,10 +2199,10 @@ ORDER BY ( SELECT COUNT(*) FROM [UnidirectionalJoinOneToBranch] AS [u0] INNER JOIN ( - SELECT [u1].[Id], [u1].[Name], [u1].[Number], NULL AS [IsGreen], N'UnidirectionalEntityBranch' AS [Discriminator] + SELECT [u1].[Id], [u1].[Name] FROM [UnidirectionalBranches] AS [u1] UNION ALL - SELECT [u2].[Id], [u2].[Name], [u2].[Number], [u2].[IsGreen], N'UnidirectionalEntityLeaf' AS [Discriminator] + SELECT [u2].[Id], [u2].[Name] FROM [UnidirectionalLeaves] AS [u2] ) AS [t] ON [u0].[UnidirectionalEntityBranchId] = [t].[Id] WHERE [u].[Id] = [u0].[UnidirectionalEntityOneId] AND [t].[Name] LIKE N'L%'), [u].[Id] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPCManyToManyQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPCManyToManyQuerySqlServerTest.cs index 5c9013bce02..553efce6b48 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPCManyToManyQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPCManyToManyQuerySqlServerTest.cs @@ -111,10 +111,10 @@ ORDER BY ( SELECT COUNT(*) FROM [JoinOneToBranch] AS [j] INNER JOIN ( - SELECT [b].[Id], [b].[Name], [b].[Number], NULL AS [IsGreen], N'EntityBranch' AS [Discriminator] + SELECT [b].[Id], [b].[Name] FROM [Branches] AS [b] UNION ALL - SELECT [l].[Id], [l].[Name], [l].[Number], [l].[IsGreen], N'EntityLeaf' AS [Discriminator] + SELECT [l].[Id], [l].[Name] FROM [Leaves] AS [l] ) AS [t] ON [j].[EntityBranchId] = [t].[Id] WHERE [e].[Id] = [j].[EntityOneId] AND [t].[Name] LIKE N'L%'), [e].[Id] @@ -2200,10 +2200,10 @@ ORDER BY ( SELECT COUNT(*) FROM [UnidirectionalJoinOneToBranch] AS [u0] INNER JOIN ( - SELECT [u1].[Id], [u1].[Name], [u1].[Number], NULL AS [IsGreen], N'UnidirectionalEntityBranch' AS [Discriminator] + SELECT [u1].[Id], [u1].[Name] FROM [UnidirectionalBranches] AS [u1] UNION ALL - SELECT [u2].[Id], [u2].[Name], [u2].[Number], [u2].[IsGreen], N'UnidirectionalEntityLeaf' AS [Discriminator] + SELECT [u2].[Id], [u2].[Name] FROM [UnidirectionalLeaves] AS [u2] ) AS [t] ON [u0].[UnidirectionalEntityBranchId] = [t].[Id] WHERE [u].[Id] = [u0].[UnidirectionalEntityOneId] AND [t].[Name] LIKE N'L%'), [u].[Id] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs index 2c344b0f87a..29a71a8b4af 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs @@ -778,11 +778,9 @@ FROM [Gears] AS [g] WHERE [g].[Rank] & COALESCE(( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] ORDER BY [g0].[Nickname], [g0].[SquadId]), 0) = COALESCE(( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] ORDER BY [g0].[Nickname], [g0].[SquadId]), 0) """, // @@ -795,11 +793,9 @@ FROM [Gears] AS [g] WHERE 2 & COALESCE(( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] ORDER BY [g0].[Nickname], [g0].[SquadId]), 0) = COALESCE(( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] ORDER BY [g0].[Nickname], [g0].[SquadId]), 0) """); } @@ -818,20 +814,13 @@ FROM [Gears] AS [g] WHERE [g].[Rank] & ( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] ORDER BY [g0].[Nickname], [g0].[SquadId]) = ( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] - ORDER BY [g0].[Nickname], [g0].[SquadId]) OR (( + ORDER BY [g0].[Nickname], [g0].[SquadId]) OR ( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] - ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL AND ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] - ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL) + ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL """, // """ @@ -843,20 +832,13 @@ FROM [Gears] AS [g] WHERE 2 & ( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] ORDER BY [g0].[Nickname], [g0].[SquadId]) = ( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] - ORDER BY [g0].[Nickname], [g0].[SquadId]) OR (( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] - ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL AND ( + ORDER BY [g0].[Nickname], [g0].[SquadId]) OR ( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] - ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL) + ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL """); } @@ -874,20 +856,13 @@ FROM [Gears] AS [g] WHERE [g].[Rank] & ( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] ORDER BY [g0].[Nickname], [g0].[SquadId]) = ( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] - ORDER BY [g0].[Nickname], [g0].[SquadId]) OR (( + ORDER BY [g0].[Nickname], [g0].[SquadId]) OR ( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] - ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL AND ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] - ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL) + ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL """); } @@ -2069,7 +2044,7 @@ FROM [Gears] AS [g] SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] INNER JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + SELECT [w0].[Id] FROM [Weapons] AS [w0] WHERE [g].[FullName] = [w0].[OwnerFullName] ) AS [t] ON [w].[Id] = [t].[Id] @@ -2093,7 +2068,7 @@ FROM [Gears] AS [g] SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + SELECT [w0].[Id] FROM [Weapons] AS [w0] WHERE [g].[FullName] = [w0].[OwnerFullName] ) AS [t] ON [w].[Id] = [t].[Id] @@ -2116,11 +2091,11 @@ FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND ( SELECT TOP(1) [t].[IsAutomatic] FROM ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + SELECT [w].[Id], [w].[IsAutomatic] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] UNION ALL - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + SELECT [w0].[Id], [w0].[IsAutomatic] FROM [Weapons] AS [w0] WHERE [g].[FullName] = [w0].[OwnerFullName] ) AS [t] @@ -2136,17 +2111,11 @@ public override async Task Concat_with_count(bool async) """ SELECT COUNT(*) FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] + SELECT 1 AS empty FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] UNION ALL - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] + SELECT 1 AS empty FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] ) AS [t] """); } @@ -2159,10 +2128,10 @@ public override async Task Concat_scalars_with_count(bool async) """ SELECT COUNT(*) FROM ( - SELECT [g].[Nickname] + SELECT 1 AS empty FROM [Gears] AS [g] UNION ALL - SELECT [g0].[FullName] AS [Nickname] + SELECT 1 AS empty FROM [Gears] AS [g0] ) AS [t] """); @@ -2176,17 +2145,11 @@ public override async Task Concat_anonymous_with_count(bool async) """ SELECT COUNT(*) FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator], [g].[Nickname] AS [Name] + SELECT 1 AS empty FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] UNION ALL - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator], [g0].[FullName] AS [Name] + SELECT 1 AS empty FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] ) AS [t] """); } @@ -2214,11 +2177,11 @@ public override async Task Select_navigation_with_concat_and_count(bool async) SELECT ( SELECT COUNT(*) FROM ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + SELECT 1 AS empty FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] UNION ALL - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + SELECT 1 AS empty FROM [Weapons] AS [w0] WHERE [g].[FullName] = [w0].[OwnerFullName] ) AS [t]) @@ -2500,7 +2463,6 @@ FROM [Cities] AS [c] WHERE [c].[Location] = 'Unknown' AND ( SELECT COUNT(*) FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] WHERE [c].[Name] = [g].[CityOfBirthName] AND [g].[Nickname] = N'Paduk') = 1 """); } @@ -3016,11 +2978,8 @@ WHEN NOT EXISTS ( SELECT 1 FROM [Tags] AS [t] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] ) AS [t0] ON [t].[GearNickName] = [t0].[Nickname] AND [t].[GearSquadId] = [t0].[SquadId] WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [t0].[HasSoulPatch] = CAST(0 AS bit)) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) @@ -3059,7 +3018,6 @@ FROM [Gears] AS [g] WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [t0].[SquadId] IN ( SELECT [g0].[SquadId] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] ) """); } @@ -3512,11 +3470,8 @@ public override async Task FirstOrDefault_with_manually_created_groupjoin_is_tra SELECT TOP(1) [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] + SELECT [g].[SquadId] FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] ) AS [t] ON [s].[Id] = [t].[SquadId] WHERE [s].[Name] = N'Kilo' """); @@ -3533,7 +3488,6 @@ FROM [Squads] AS [s] WHERE NOT EXISTS ( SELECT 1 FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] WHERE [s].[Id] = [g].[SquadId] AND [t].[Note] = N'Dom''s Tag') """); @@ -3549,7 +3503,6 @@ SELECT CASE WHEN NOT EXISTS ( SELECT 1 FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] WHERE [t].[Note] = N'Foo' AND [t].[Note] IS NOT NULL) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) @@ -3995,7 +3948,6 @@ public override async Task Collection_navigation_access_on_derived_entity_using_ SELECT [f].[Name], ( SELECT COUNT(*) FROM [LocustLeaders] AS [l0] - LEFT JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] WHERE [f].[Id] = [l0].[LocustHordeId]) AS [LeadersCount] FROM [Factions] AS [f] LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] @@ -4182,7 +4134,6 @@ FROM [Gears] AS [g] WHERE [t0].[Discriminator] = N'Officer' AND ( SELECT COUNT(*) FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] WHERE [t0].[Nickname] IS NOT NULL AND [t0].[SquadId] IS NOT NULL AND [t0].[Nickname] = [g0].[LeaderNickname] AND [t0].[SquadId] = [g0].[LeaderSquadId] AND [g0].[Nickname] = N'Dom') > 0 """); } @@ -5127,7 +5078,6 @@ FROM [Gears] AS [g] WHERE [o].[Nickname] IS NOT NULL AND EXISTS ( SELECT 1 FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) ORDER BY [g].[HasSoulPatch] DESC, [t].[Note] """); @@ -5158,7 +5108,6 @@ FROM [Gears] AS [g2] WHERE [o].[Nickname] IS NOT NULL AND EXISTS ( SELECT 1 FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [t0].[Nickname], [t0].[SquadId], [t1].[IsAutomatic], [t1].[Nickname] DESC, [t1].[Id] """); @@ -5190,7 +5139,6 @@ FROM [Gears] AS [g2] WHERE [o].[Nickname] IS NOT NULL AND EXISTS ( SELECT 1 FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [t0].[Nickname], [t0].[SquadId], [t1].[IsAutomatic], [t1].[Nickname] DESC, [t1].[Id] """); @@ -5225,7 +5173,6 @@ FROM [Gears] AS [g2] WHERE [o].[Nickname] IS NOT NULL AND EXISTS ( SELECT 1 FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [t0].[Nickname], [t0].[SquadId], [t1].[Id] DESC, [t1].[c], [t1].[Nickname] """); @@ -5276,7 +5223,6 @@ FROM [Gears] AS [g5] WHERE [o].[Nickname] IS NOT NULL AND EXISTS ( SELECT 1 FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [t0].[Nickname], [t0].[SquadId], [t2].[Rank], [t2].[Nickname], [t2].[SquadId], [t2].[IsAutomatic0], [t2].[Id], [t2].[Nickname0], [t2].[SquadId0], [t2].[Id0], [t2].[Id1], [t2].[Nickname00], [t2].[SquadId00], [t5].[IsAutomatic], [t5].[Nickname] DESC, [t5].[Id] """); @@ -5475,7 +5421,6 @@ public override async Task Correlated_collections_with_FirstOrDefault(bool async SELECT ( SELECT TOP(1) [g].[FullName] FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] WHERE [s].[Id] = [g].[SquadId] ORDER BY [g].[Nickname]) FROM [Squads] AS [s] @@ -6190,7 +6135,6 @@ public override async Task Project_one_value_type_from_empty_collection(bool asy SELECT [s].[Name], COALESCE(( SELECT TOP(1) [g].[SquadId] FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)), 0) AS [SquadId] FROM [Squads] AS [s] WHERE [s].[Name] = N'Kilo' @@ -6206,7 +6150,6 @@ public override async Task Project_one_value_type_converted_to_nullable_from_emp SELECT [s].[Name], ( SELECT TOP(1) [g].[SquadId] FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)) AS [SquadId] FROM [Squads] AS [s] WHERE [s].[Name] = N'Kilo' @@ -6245,7 +6188,6 @@ FROM [Squads] AS [s] WHERE [s].[Name] = N'Kilo' AND COALESCE(( SELECT TOP(1) [g].[SquadId] FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)), 0) <> 0 """); } @@ -6259,7 +6201,6 @@ public override async Task Select_subquery_projecting_single_constant_int(bool a SELECT [s].[Name], COALESCE(( SELECT TOP(1) 42 FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)), 0) AS [Gear] FROM [Squads] AS [s] """); @@ -6274,7 +6215,6 @@ public override async Task Select_subquery_projecting_single_constant_string(boo SELECT [s].[Name], ( SELECT TOP(1) N'Foo' FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)) AS [Gear] FROM [Squads] AS [s] """); @@ -6289,7 +6229,6 @@ public override async Task Select_subquery_projecting_single_constant_bool(bool SELECT [s].[Name], COALESCE(( SELECT TOP(1) CAST(1 AS bit) FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)), CAST(0 AS bit)) AS [Gear] FROM [Squads] AS [s] """); @@ -6536,7 +6475,6 @@ FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[IsAutomatic] = COALESCE(( SELECT TOP(1) [g0].[HasSoulPatch] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] WHERE [g0].[Nickname] = N'Marcus'), CAST(0 AS bit))), [g].[Nickname], [g].[SquadId], [t].[Nickname] """); } @@ -7548,7 +7486,6 @@ FROM [Cities] AS [c] WHERE EXISTS ( SELECT 1 FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] WHERE [c].[Name] = [g0].[CityOfBirthName] AND [g0].[Nickname] = [g].[Nickname] AND [g0].[SquadId] = [g].[SquadId])) """); } @@ -7607,7 +7544,6 @@ FROM [Cities] AS [c] WHERE ( SELECT TOP(1) [g].[HasSoulPatch] FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) = CAST(1 AS bit) """); } @@ -7804,11 +7740,8 @@ END AS [Discriminator] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] INNER JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] + SELECT [g0].[Nickname] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] ) AS [t] ON [g].[Nickname] = [t].[Nickname] """); } @@ -7825,11 +7758,8 @@ END AS [Discriminator] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] INNER JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] + SELECT [g0].[Nickname] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] ) AS [t] ON [g].[Nickname] = [t].[Nickname] """); } @@ -8195,7 +8125,6 @@ FROM [Squads] AS [s] WHERE EXISTS ( SELECT 1 FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] WHERE [s].[Id] = [g].[SquadId] AND [g].[SquadId] = @__gearId_0 AND [g].[SquadId] = @__gearId_0) """); } @@ -8505,12 +8434,10 @@ FROM [Gears] AS [g] WHERE [c].[Name] = ( SELECT TOP(1) [c0].[Name] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] INNER JOIN [Cities] AS [c0] ON [g0].[CityOfBirthName] = [c0].[Name] ORDER BY [g0].[Nickname]) OR ([c].[Name] IS NULL AND ( SELECT TOP(1) [c0].[Name] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] INNER JOIN [Cities] AS [c0] ON [g0].[CityOfBirthName] = [c0].[Name] ORDER BY [g0].[Nickname]) IS NULL) """); @@ -9037,7 +8964,6 @@ FROM [LocustLeaders] AS [l] WHERE [l].[ThreatLevelByte] IN ( SELECT [l1].[ThreatLevelByte] FROM [LocustLeaders] AS [l1] - LEFT JOIN [LocustCommanders] AS [l2] ON [l1].[Name] = [l2].[Name] ) """); } @@ -9056,7 +8982,6 @@ FROM [LocustLeaders] AS [l] WHERE EXISTS ( SELECT 1 FROM [LocustLeaders] AS [l1] - LEFT JOIN [LocustCommanders] AS [l2] ON [l1].[Name] = [l2].[Name] WHERE [l1].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l1].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL)) """); } @@ -9075,7 +9000,6 @@ FROM [LocustLeaders] AS [l] WHERE EXISTS ( SELECT 1 FROM [LocustLeaders] AS [l1] - LEFT JOIN [LocustCommanders] AS [l2] ON [l1].[Name] = [l2].[Name] WHERE [l1].[ThreatLevelNullableByte] IS NULL) """); } @@ -9094,7 +9018,6 @@ FROM [LocustLeaders] AS [l] WHERE EXISTS ( SELECT 1 FROM [LocustLeaders] AS [l1] - LEFT JOIN [LocustCommanders] AS [l2] ON [l1].[Name] = [l2].[Name] WHERE [l1].[ThreatLevelNullableByte] IS NULL) """); } @@ -9136,7 +9059,6 @@ FROM [Gears] AS [g] WHERE [l].[ThreatLevelByte] IN ( SELECT [l1].[ThreatLevelByte] FROM [LocustLeaders] AS [l1] - LEFT JOIN [LocustCommanders] AS [l2] ON [l1].[Name] = [l2].[Name] ) ) AS [t] """); @@ -9160,7 +9082,6 @@ FROM [Gears] AS [g] WHERE [l].[ThreatLevelByte] NOT IN ( SELECT [l1].[ThreatLevelByte] FROM [LocustLeaders] AS [l1] - LEFT JOIN [LocustCommanders] AS [l2] ON [l1].[Name] = [l2].[Name] ) ) AS [t] """); @@ -9183,7 +9104,6 @@ FROM [Gears] AS [g] WHERE EXISTS ( SELECT 1 FROM [LocustLeaders] AS [l1] - LEFT JOIN [LocustCommanders] AS [l2] ON [l1].[Name] = [l2].[Name] WHERE [l1].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l1].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL)) ) AS [t] """); @@ -9206,7 +9126,6 @@ FROM [Gears] AS [g] WHERE NOT EXISTS ( SELECT 1 FROM [LocustLeaders] AS [l1] - LEFT JOIN [LocustCommanders] AS [l2] ON [l1].[Name] = [l2].[Name] WHERE [l1].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l1].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL)) ) AS [t] """); @@ -9485,7 +9404,6 @@ FROM [Squads] AS [s] WHERE [s].[Name] = N'Delta' AND COALESCE(( SELECT TOP(1) [g].[SquadId] FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit) ORDER BY [g].[FullName]), 0) <> 0 """); @@ -11186,7 +11104,6 @@ FROM [Squads] AS [s] WHERE NOT EXISTS ( SELECT 1 FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] WHERE [s].[Id] = [g].[SquadId]) """); } @@ -11202,7 +11119,6 @@ FROM [Squads] AS [s] WHERE NOT EXISTS ( SELECT 1 FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] WHERE [s].[Id] = [g].[SquadId] AND [g].[FullName] = N'Anthony Carmine') """); } @@ -11374,7 +11290,6 @@ FROM [Squads] AS [s] WHERE NOT EXISTS ( SELECT 1 FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] WHERE [s].[Id] = [g].[SquadId] ORDER BY [g].[Nickname] OFFSET 2 ROWS) @@ -11392,7 +11307,6 @@ FROM [Squads] AS [s] WHERE ( SELECT [g].[Nickname] FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] WHERE [s].[Id] = [g].[SquadId] ORDER BY [g].[Nickname] OFFSET [s].[Id] ROWS FETCH NEXT 1 ROWS ONLY) = N'Cole Train' @@ -11467,42 +11381,23 @@ public override async Task Set_operator_with_navigation_in_projection_groupby_ag SELECT [s].[Name], ( SELECT COALESCE(SUM(CAST(LEN([c].[Location]) AS int)), 0) FROM [Gears] AS [g2] - LEFT JOIN [Officers] AS [o2] ON [g2].[Nickname] = [o2].[Nickname] AND [g2].[SquadId] = [o2].[SquadId] INNER JOIN [Squads] AS [s0] ON [g2].[SquadId] = [s0].[Id] INNER JOIN [Cities] AS [c] ON [g2].[CityOfBirthName] = [c].[Name] WHERE N'Marcus' IN ( - SELECT [t0].[Nickname] - FROM ( - SELECT [g3].[Nickname], [g3].[SquadId], [g3].[AssignedCityName], [g3].[CityOfBirthName], [g3].[FullName], [g3].[HasSoulPatch], [g3].[LeaderNickname], [g3].[LeaderSquadId], [g3].[Rank], CASE - WHEN [o3].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g3] - LEFT JOIN [Officers] AS [o3] ON [g3].[Nickname] = [o3].[Nickname] AND [g3].[SquadId] = [o3].[SquadId] - UNION ALL - SELECT [g4].[Nickname], [g4].[SquadId], [g4].[AssignedCityName], [g4].[CityOfBirthName], [g4].[FullName], [g4].[HasSoulPatch], [g4].[LeaderNickname], [g4].[LeaderSquadId], [g4].[Rank], CASE - WHEN [o4].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g4] - LEFT JOIN [Officers] AS [o4] ON [g4].[Nickname] = [o4].[Nickname] AND [g4].[SquadId] = [o4].[SquadId] - ) AS [t0] + SELECT [g3].[Nickname] + FROM [Gears] AS [g3] + UNION ALL + SELECT [g4].[Nickname] + FROM [Gears] AS [g4] ) AND ([s].[Name] = [s0].[Name] OR ([s].[Name] IS NULL AND [s0].[Name] IS NULL))) AS [SumOfLengths] FROM [Gears] AS [g] INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] WHERE N'Marcus' IN ( - SELECT [t].[Nickname] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] - UNION ALL - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank], CASE - WHEN [o1].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g1] - LEFT JOIN [Officers] AS [o1] ON [g1].[Nickname] = [o1].[Nickname] AND [g1].[SquadId] = [o1].[SquadId] - ) AS [t] + SELECT [g0].[Nickname] + FROM [Gears] AS [g0] + UNION ALL + SELECT [g1].[Nickname] + FROM [Gears] AS [g1] ) GROUP BY [s].[Name] """); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTInheritanceQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTInheritanceQuerySqlServerTest.cs index 61b513def64..f1c416b54c8 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTInheritanceQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTInheritanceQuerySqlServerTest.cs @@ -616,13 +616,8 @@ FROM [Animals] AS [a] WHERE EXISTS ( SELECT 1 FROM ( - SELECT TOP(1) [a0].[Id], [a0].[CountryId], [a0].[Name], [a0].[Species], [b0].[EagleId], [b0].[IsFlightless], [e0].[Group], [k0].[FoundOn], CASE - WHEN [k0].[Id] IS NOT NULL THEN N'Kiwi' - WHEN [e0].[Id] IS NOT NULL THEN N'Eagle' - END AS [Discriminator], [k0].[Id] AS [Id0] + SELECT TOP(1) [k0].[Id] AS [Id0] FROM [Animals] AS [a0] - LEFT JOIN [Birds] AS [b0] ON [a0].[Id] = [b0].[Id] - LEFT JOIN [Eagle] AS [e0] ON [a0].[Id] = [e0].[Id] LEFT JOIN [Kiwi] AS [k0] ON [a0].[Id] = [k0].[Id] WHERE [a0].[Name] = N'Great spotted kiwi' ) AS [t] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySqlServerTest.cs index defe53ce14c..554fab10c11 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySqlServerTest.cs @@ -112,12 +112,9 @@ ORDER BY ( SELECT COUNT(*) FROM [JoinOneToBranch] AS [j] INNER JOIN ( - SELECT [r].[Id], [r].[Name], [b].[Number], [l].[IsGreen], CASE - WHEN [l].[Id] IS NOT NULL THEN N'EntityLeaf' - END AS [Discriminator] + SELECT [r].[Id], [r].[Name] FROM [Roots] AS [r] INNER JOIN [Branches] AS [b] ON [r].[Id] = [b].[Id] - LEFT JOIN [Leaves] AS [l] ON [r].[Id] = [l].[Id] ) AS [t] ON [j].[EntityBranchId] = [t].[Id] WHERE [e].[Id] = [j].[EntityOneId] AND [t].[Name] LIKE N'L%'), [e].[Id] """); @@ -2151,12 +2148,9 @@ ORDER BY ( SELECT COUNT(*) FROM [UnidirectionalJoinOneToBranch] AS [u0] INNER JOIN ( - SELECT [u1].[Id], [u1].[Name], [u2].[Number], [u3].[IsGreen], CASE - WHEN [u3].[Id] IS NOT NULL THEN N'UnidirectionalEntityLeaf' - END AS [Discriminator] + SELECT [u1].[Id], [u1].[Name] FROM [UnidirectionalRoots] AS [u1] INNER JOIN [UnidirectionalBranches] AS [u2] ON [u1].[Id] = [u2].[Id] - LEFT JOIN [UnidirectionalLeaves] AS [u3] ON [u1].[Id] = [u3].[Id] ) AS [t] ON [u0].[UnidirectionalEntityBranchId] = [t].[Id] WHERE [u].[Id] = [u0].[UnidirectionalEntityOneId] AND [t].[Name] LIKE N'L%'), [u].[Id] """); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyQuerySqlServerTest.cs index 8ed4d6739ce..d5fe40fb868 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyQuerySqlServerTest.cs @@ -111,12 +111,9 @@ ORDER BY ( SELECT COUNT(*) FROM [JoinOneToBranch] AS [j] INNER JOIN ( - SELECT [r].[Id], [r].[Name], [b].[Number], [l].[IsGreen], CASE - WHEN [l].[Id] IS NOT NULL THEN N'EntityLeaf' - END AS [Discriminator] + SELECT [r].[Id], [r].[Name] FROM [Roots] AS [r] INNER JOIN [Branches] AS [b] ON [r].[Id] = [b].[Id] - LEFT JOIN [Leaves] AS [l] ON [r].[Id] = [l].[Id] ) AS [t] ON [j].[EntityBranchId] = [t].[Id] WHERE [e].[Id] = [j].[EntityOneId] AND [t].[Name] LIKE N'L%'), [e].[Id] """); @@ -2151,12 +2148,9 @@ ORDER BY ( SELECT COUNT(*) FROM [UnidirectionalJoinOneToBranch] AS [u0] INNER JOIN ( - SELECT [u1].[Id], [u1].[Name], [u2].[Number], [u3].[IsGreen], CASE - WHEN [u3].[Id] IS NOT NULL THEN N'UnidirectionalEntityLeaf' - END AS [Discriminator] + SELECT [u1].[Id], [u1].[Name] FROM [UnidirectionalRoots] AS [u1] INNER JOIN [UnidirectionalBranches] AS [u2] ON [u1].[Id] = [u2].[Id] - LEFT JOIN [UnidirectionalLeaves] AS [u3] ON [u1].[Id] = [u3].[Id] ) AS [t] ON [u0].[UnidirectionalEntityBranchId] = [t].[Id] WHERE [u].[Id] = [u0].[UnidirectionalEntityOneId] AND [t].[Name] LIKE N'L%'), [u].[Id] """); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs index e2b8f9fe1a2..9e9bdd2e9e6 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs @@ -1337,7 +1337,7 @@ WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] SELECT COUNT(*) FROM [Level1] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] LEFT JOIN ( - SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Level3_Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[PeriodEnd], [l1].[PeriodStart] + SELECT [l1].[Level3_Name], [l1].[OneToOne_Optional_PK_Inverse3Id] FROM [Level1] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l1] WHERE [l1].[Level2_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse3Id] IS NOT NULL ) AS [t] ON CASE diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs index 7860e5c1c3d..bcee3b3fc09 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs @@ -826,7 +826,7 @@ public override async Task Where_subquery_left_join_firstordefault_boolean(bool SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[PeriodEnd], [w0].[PeriodStart], [w0].[SynergyWithId] + SELECT [w0].[Id] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w0] WHERE [g].[FullName] = [w0].[OwnerFullName] ) AS [t] ON [w].[Id] = [t].[Id] @@ -2625,11 +2625,11 @@ public override async Task Where_subquery_concat_firstordefault_boolean(bool asy WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND ( SELECT TOP(1) [t].[IsAutomatic] FROM ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] + SELECT [w].[Id], [w].[IsAutomatic] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] UNION ALL - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[PeriodEnd], [w0].[PeriodStart], [w0].[SynergyWithId] + SELECT [w0].[Id], [w0].[IsAutomatic] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w0] WHERE [g].[FullName] = [w0].[OwnerFullName] ) AS [t] @@ -6412,10 +6412,10 @@ public override async Task Concat_with_count(bool async) """ SELECT COUNT(*) FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[PeriodEnd], [g].[PeriodStart], [g].[Rank] + SELECT 1 AS empty FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] UNION ALL - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[PeriodEnd], [g0].[PeriodStart], [g0].[Rank] + SELECT 1 AS empty FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] ) AS [t] """); @@ -7222,10 +7222,10 @@ public override async Task Concat_scalars_with_count(bool async) """ SELECT COUNT(*) FROM ( - SELECT [g].[Nickname] + SELECT 1 AS empty FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] UNION ALL - SELECT [g0].[FullName] AS [Nickname] + SELECT 1 AS empty FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] ) AS [t] """); @@ -8329,10 +8329,10 @@ public override async Task Concat_anonymous_with_count(bool async) """ SELECT COUNT(*) FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[PeriodEnd], [g].[PeriodStart], [g].[Rank], [g].[Nickname] AS [Name] + SELECT 1 AS empty FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] UNION ALL - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[PeriodEnd], [g0].[PeriodStart], [g0].[Rank], [g0].[FullName] AS [Name] + SELECT 1 AS empty FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] ) AS [t] """); @@ -8573,11 +8573,11 @@ public override async Task Select_navigation_with_concat_and_count(bool async) SELECT ( SELECT COUNT(*) FROM ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] + SELECT 1 AS empty FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] UNION ALL - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[PeriodEnd], [w0].[PeriodStart], [w0].[SynergyWithId] + SELECT 1 AS empty FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w0] WHERE [g].[FullName] = [w0].[OwnerFullName] ) AS [t]) @@ -8816,7 +8816,7 @@ public override async Task Where_subquery_join_firstordefault_boolean(bool async SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] INNER JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[PeriodEnd], [w0].[PeriodStart], [w0].[SynergyWithId] + SELECT [w0].[Id] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w0] WHERE [g].[FullName] = [w0].[OwnerFullName] ) AS [t] ON [w].[Id] = [t].[Id] @@ -10020,26 +10020,20 @@ SELECT COALESCE(SUM(CAST(LEN([c].[Location]) AS int)), 0) INNER JOIN [Squads] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s0] ON [g2].[SquadId] = [s0].[Id] INNER JOIN [Cities] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [c] ON [g2].[CityOfBirthName] = [c].[Name] WHERE N'Marcus' IN ( - SELECT [t0].[Nickname] - FROM ( - SELECT [g3].[Nickname], [g3].[SquadId], [g3].[AssignedCityName], [g3].[CityOfBirthName], [g3].[Discriminator], [g3].[FullName], [g3].[HasSoulPatch], [g3].[LeaderNickname], [g3].[LeaderSquadId], [g3].[PeriodEnd], [g3].[PeriodStart], [g3].[Rank] - FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g3] - UNION ALL - SELECT [g4].[Nickname], [g4].[SquadId], [g4].[AssignedCityName], [g4].[CityOfBirthName], [g4].[Discriminator], [g4].[FullName], [g4].[HasSoulPatch], [g4].[LeaderNickname], [g4].[LeaderSquadId], [g4].[PeriodEnd], [g4].[PeriodStart], [g4].[Rank] - FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g4] - ) AS [t0] + SELECT [g3].[Nickname] + FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g3] + UNION ALL + SELECT [g4].[Nickname] + FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g4] ) AND ([s].[Name] = [s0].[Name] OR ([s].[Name] IS NULL AND [s0].[Name] IS NULL))) AS [SumOfLengths] FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] INNER JOIN [Squads] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s] ON [g].[SquadId] = [s].[Id] WHERE N'Marcus' IN ( - SELECT [t].[Nickname] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[PeriodEnd], [g0].[PeriodStart], [g0].[Rank] - FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] - UNION ALL - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[PeriodEnd], [g1].[PeriodStart], [g1].[Rank] - FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g1] - ) AS [t] + SELECT [g0].[Nickname] + FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] + UNION ALL + SELECT [g1].[Nickname] + FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g1] ) GROUP BY [s].[Name] """); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalManyToManyQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalManyToManyQuerySqlServerTest.cs index 7917e269d1b..eadfcefd184 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalManyToManyQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalManyToManyQuerySqlServerTest.cs @@ -138,7 +138,7 @@ ORDER BY ( SELECT COUNT(*) FROM [JoinOneToBranch] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [j] INNER JOIN ( - SELECT [e0].[Id], [e0].[Discriminator], [e0].[Name], [e0].[PeriodEnd], [e0].[PeriodStart], [e0].[Number], [e0].[IsGreen] + SELECT [e0].[Id], [e0].[Name] FROM [EntityRoots] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [e0] WHERE [e0].[Discriminator] IN (N'EntityBranch', N'EntityLeaf') ) AS [t] ON [j].[EntityBranchId] = [t].[Id] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalOwnedQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalOwnedQuerySqlServerTest.cs index b8db03bd507..bc75f321c30 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalOwnedQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalOwnedQuerySqlServerTest.cs @@ -1298,7 +1298,7 @@ public override async Task GroupBy_with_multiple_aggregates_on_owned_navigation_ SELECT ( SELECT AVG(CAST([s].[Id] AS float)) FROM ( - SELECT [o0].[Id], [o0].[Discriminator], [o0].[Name], [o0].[PeriodEnd], [o0].[PeriodStart], 1 AS [Key], [o0].[PersonAddress_AddressLine], [o0].[PeriodEnd] AS [PeriodEnd0], [o0].[PeriodStart] AS [PeriodStart0], [o0].[PersonAddress_PlaceType], [o0].[PersonAddress_ZipCode], [o0].[PersonAddress_Country_Name], [o0].[PersonAddress_Country_PlanetId] + SELECT 1 AS [Key], [o0].[PersonAddress_Country_PlanetId] FROM [OwnedPerson] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [o0] ) AS [t0] LEFT JOIN [Planet] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [p] ON [t0].[PersonAddress_Country_PlanetId] = [p].[Id] @@ -1306,7 +1306,7 @@ SELECT AVG(CAST([s].[Id] AS float)) WHERE [t].[Key] = [t0].[Key]) AS [p1], ( SELECT COALESCE(SUM([s0].[Id]), 0) FROM ( - SELECT [o1].[Id], [o1].[Discriminator], [o1].[Name], [o1].[PeriodEnd], [o1].[PeriodStart], 1 AS [Key], [o1].[PersonAddress_AddressLine], [o1].[PeriodEnd] AS [PeriodEnd0], [o1].[PeriodStart] AS [PeriodStart0], [o1].[PersonAddress_PlaceType], [o1].[PersonAddress_ZipCode], [o1].[PersonAddress_Country_Name], [o1].[PersonAddress_Country_PlanetId] + SELECT 1 AS [Key], [o1].[PersonAddress_Country_PlanetId] FROM [OwnedPerson] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [o1] ) AS [t1] LEFT JOIN [Planet] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [p0] ON [t1].[PersonAddress_Country_PlanetId] = [p0].[Id] @@ -1314,7 +1314,7 @@ SELECT COALESCE(SUM([s0].[Id]), 0) WHERE [t].[Key] = [t1].[Key]) AS [p2], ( SELECT MAX(CAST(LEN([s1].[Name]) AS int)) FROM ( - SELECT [o2].[Id], [o2].[Discriminator], [o2].[Name], [o2].[PeriodEnd], [o2].[PeriodStart], 1 AS [Key], [o2].[PersonAddress_AddressLine], [o2].[PeriodEnd] AS [PeriodEnd0], [o2].[PeriodStart] AS [PeriodStart0], [o2].[PersonAddress_PlaceType], [o2].[PersonAddress_ZipCode], [o2].[PersonAddress_Country_Name], [o2].[PersonAddress_Country_PlanetId] + SELECT 1 AS [Key], [o2].[PersonAddress_Country_PlanetId] FROM [OwnedPerson] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [o2] ) AS [t2] LEFT JOIN [Planet] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [p1] ON [t2].[PersonAddress_Country_PlanetId] = [p1].[Id] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/UdfDbFunctionSqlServerTests.cs b/test/EFCore.SqlServer.FunctionalTests/Query/UdfDbFunctionSqlServerTests.cs index d3bce765060..6ec09bc44a5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/UdfDbFunctionSqlServerTests.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/UdfDbFunctionSqlServerTests.cs @@ -697,7 +697,7 @@ public override void QF_Select_Correlated_Subquery_In_Anonymous_Nested_With_QF() SELECT [o].[CustomerId], [o].[OrderDate] FROM [Orders] AS [o] INNER JOIN ( - SELECT [c].[Id], [c].[FirstName], [c].[LastName], [g].[OrderId], [g].[CustomerId], [g].[OrderDate] + SELECT [g].[OrderId] FROM [Customers] AS [c] CROSS APPLY [dbo].[GetOrdersWithMultipleProducts]([c].[Id]) AS [g] ) AS [t] ON [o].[Id] = [t].[OrderId] diff --git a/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesSqliteTest.cs index f39a04f9daa..3064635eaa4 100644 --- a/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesSqliteTest.cs @@ -93,6 +93,8 @@ public override async Task Update_non_main_table_in_entity_with_entity_splitting UPDATE "BlogsPart1" AS "b0" SET "Rating" = length("b0"."Title"), "Title" = CAST("b0"."Rating" AS TEXT) +FROM "Blogs" AS "b" +WHERE "b"."Id" = "b0"."Id" """); } diff --git a/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqliteTest.cs index 864dba61a6b..b11fc6dedd3 100644 --- a/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqliteTest.cs @@ -86,7 +86,7 @@ DELETE FROM "Order Details" AS "o" WHERE EXISTS ( SELECT 1 FROM ( - SELECT "o0"."OrderID", "o0"."ProductID", "o0"."Discount", "o0"."Quantity", "o0"."UnitPrice" + SELECT "o0"."OrderID", "o0"."ProductID" FROM "Order Details" AS "o0" WHERE "o0"."OrderID" < 10300 ORDER BY "o0"."OrderID" @@ -108,7 +108,7 @@ DELETE FROM "Order Details" AS "o" WHERE EXISTS ( SELECT 1 FROM ( - SELECT "o0"."OrderID", "o0"."ProductID", "o0"."Discount", "o0"."Quantity", "o0"."UnitPrice" + SELECT "o0"."OrderID", "o0"."ProductID" FROM "Order Details" AS "o0" WHERE "o0"."OrderID" < 10300 ORDER BY "o0"."OrderID" @@ -130,7 +130,7 @@ DELETE FROM "Order Details" AS "o" WHERE EXISTS ( SELECT 1 FROM ( - SELECT "o0"."OrderID", "o0"."ProductID", "o0"."Discount", "o0"."Quantity", "o0"."UnitPrice" + SELECT "o0"."OrderID", "o0"."ProductID" FROM "Order Details" AS "o0" WHERE "o0"."OrderID" < 10300 ORDER BY "o0"."OrderID" @@ -152,7 +152,7 @@ DELETE FROM "Order Details" AS "o" WHERE EXISTS ( SELECT 1 FROM ( - SELECT "o0"."OrderID", "o0"."ProductID", "o0"."Discount", "o0"."Quantity", "o0"."UnitPrice" + SELECT "o0"."OrderID", "o0"."ProductID" FROM "Order Details" AS "o0" WHERE "o0"."OrderID" < 10300 LIMIT -1 OFFSET @__p_0 @@ -173,7 +173,7 @@ DELETE FROM "Order Details" AS "o" WHERE EXISTS ( SELECT 1 FROM ( - SELECT "o0"."OrderID", "o0"."ProductID", "o0"."Discount", "o0"."Quantity", "o0"."UnitPrice" + SELECT "o0"."OrderID", "o0"."ProductID" FROM "Order Details" AS "o0" WHERE "o0"."OrderID" < 10300 LIMIT @__p_0 @@ -194,7 +194,7 @@ DELETE FROM "Order Details" AS "o" WHERE EXISTS ( SELECT 1 FROM ( - SELECT "o0"."OrderID", "o0"."ProductID", "o0"."Discount", "o0"."Quantity", "o0"."UnitPrice" + SELECT "o0"."OrderID", "o0"."ProductID" FROM "Order Details" AS "o0" WHERE "o0"."OrderID" < 10300 LIMIT @__p_0 OFFSET @__p_0 @@ -275,9 +275,9 @@ DELETE FROM "Order Details" AS "o" WHERE EXISTS ( SELECT 1 FROM ( - SELECT "t"."OrderID", "t"."ProductID", "t"."Discount", "t"."Quantity", "t"."UnitPrice" + SELECT "t"."OrderID", "t"."ProductID" FROM ( - SELECT "o0"."OrderID", "o0"."ProductID", "o0"."Discount", "o0"."Quantity", "o0"."UnitPrice" + SELECT "o0"."OrderID", "o0"."ProductID" FROM "Order Details" AS "o0" WHERE "o0"."OrderID" < 10300 LIMIT @__p_0 OFFSET @__p_0 @@ -325,7 +325,7 @@ WHERE EXISTS ( SELECT 1 FROM "Orders" AS "o0" INNER JOIN ( - SELECT "o1"."OrderID", "o1"."ProductID", "o1"."Discount", "o1"."Quantity", "o1"."UnitPrice" + SELECT "o1"."OrderID", "o1"."ProductID" FROM "Order Details" AS "o1" WHERE "o1"."ProductID" > 0 ) AS "t" ON "o0"."OrderID" = "t"."OrderID" @@ -396,11 +396,11 @@ DELETE FROM "Order Details" AS "o" WHERE EXISTS ( SELECT 1 FROM ( - SELECT "o0"."OrderID", "o0"."ProductID", "o0"."Discount", "o0"."Quantity", "o0"."UnitPrice" + SELECT "o0"."OrderID", "o0"."ProductID" FROM "Order Details" AS "o0" WHERE "o0"."OrderID" < 10250 UNION ALL - SELECT "o1"."OrderID", "o1"."ProductID", "o1"."Discount", "o1"."Quantity", "o1"."UnitPrice" + SELECT "o1"."OrderID", "o1"."ProductID" FROM "Order Details" AS "o1" WHERE "o1"."OrderID" > 11250 ) AS "t" @@ -521,7 +521,7 @@ WHERE EXISTS ( SELECT 1 FROM "Order Details" AS "o0" INNER JOIN ( - SELECT "o1"."OrderID", "o1"."CustomerID", "o1"."EmployeeID", "o1"."OrderDate" + SELECT "o1"."OrderID" FROM "Orders" AS "o1" WHERE "o1"."OrderID" < 10300 ORDER BY "o1"."OrderID" @@ -545,7 +545,7 @@ WHERE EXISTS ( SELECT 1 FROM "Order Details" AS "o0" LEFT JOIN ( - SELECT "o1"."OrderID", "o1"."CustomerID", "o1"."EmployeeID", "o1"."OrderDate" + SELECT "o1"."OrderID" FROM "Orders" AS "o1" WHERE "o1"."OrderID" < 10300 ORDER BY "o1"."OrderID" @@ -566,7 +566,7 @@ WHERE EXISTS ( SELECT 1 FROM "Order Details" AS "o0" CROSS JOIN ( - SELECT "o1"."OrderID", "o1"."CustomerID", "o1"."EmployeeID", "o1"."OrderDate" + SELECT 1 FROM "Orders" AS "o1" WHERE "o1"."OrderID" < 10300 ORDER BY "o1"."OrderID" @@ -711,7 +711,7 @@ public override async Task Update_Where_Skip_set_constant(bool async) UPDATE "Customers" AS "c" SET "ContactName" = 'Updated' FROM ( - SELECT "c0"."CustomerID", "c0"."Address", "c0"."City", "c0"."CompanyName", "c0"."ContactName", "c0"."ContactTitle", "c0"."Country", "c0"."Fax", "c0"."Phone", "c0"."PostalCode", "c0"."Region" + SELECT "c0"."CustomerID" FROM "Customers" AS "c0" WHERE "c0"."CustomerID" LIKE 'F%' LIMIT -1 OFFSET @__p_0 @@ -731,7 +731,7 @@ public override async Task Update_Where_Take_set_constant(bool async) UPDATE "Customers" AS "c" SET "ContactName" = 'Updated' FROM ( - SELECT "c0"."CustomerID", "c0"."Address", "c0"."City", "c0"."CompanyName", "c0"."ContactName", "c0"."ContactTitle", "c0"."Country", "c0"."Fax", "c0"."Phone", "c0"."PostalCode", "c0"."Region" + SELECT "c0"."CustomerID" FROM "Customers" AS "c0" WHERE "c0"."CustomerID" LIKE 'F%' LIMIT @__p_0 @@ -752,7 +752,7 @@ public override async Task Update_Where_Skip_Take_set_constant(bool async) UPDATE "Customers" AS "c" SET "ContactName" = 'Updated' FROM ( - SELECT "c0"."CustomerID", "c0"."Address", "c0"."City", "c0"."CompanyName", "c0"."ContactName", "c0"."ContactTitle", "c0"."Country", "c0"."Fax", "c0"."Phone", "c0"."PostalCode", "c0"."Region" + SELECT "c0"."CustomerID" FROM "Customers" AS "c0" WHERE "c0"."CustomerID" LIKE 'F%' LIMIT @__p_1 OFFSET @__p_0 @@ -770,7 +770,7 @@ public override async Task Update_Where_OrderBy_set_constant(bool async) UPDATE "Customers" AS "c" SET "ContactName" = 'Updated' FROM ( - SELECT "c0"."CustomerID", "c0"."Address", "c0"."City", "c0"."CompanyName", "c0"."ContactName", "c0"."ContactTitle", "c0"."Country", "c0"."Fax", "c0"."Phone", "c0"."PostalCode", "c0"."Region" + SELECT "c0"."CustomerID" FROM "Customers" AS "c0" WHERE "c0"."CustomerID" LIKE 'F%' ) AS "t" @@ -789,7 +789,7 @@ public override async Task Update_Where_OrderBy_Skip_set_constant(bool async) UPDATE "Customers" AS "c" SET "ContactName" = 'Updated' FROM ( - SELECT "c0"."CustomerID", "c0"."Address", "c0"."City", "c0"."CompanyName", "c0"."ContactName", "c0"."ContactTitle", "c0"."Country", "c0"."Fax", "c0"."Phone", "c0"."PostalCode", "c0"."Region" + SELECT "c0"."CustomerID" FROM "Customers" AS "c0" WHERE "c0"."CustomerID" LIKE 'F%' ORDER BY "c0"."City" @@ -810,7 +810,7 @@ public override async Task Update_Where_OrderBy_Take_set_constant(bool async) UPDATE "Customers" AS "c" SET "ContactName" = 'Updated' FROM ( - SELECT "c0"."CustomerID", "c0"."Address", "c0"."City", "c0"."CompanyName", "c0"."ContactName", "c0"."ContactTitle", "c0"."Country", "c0"."Fax", "c0"."Phone", "c0"."PostalCode", "c0"."Region" + SELECT "c0"."CustomerID" FROM "Customers" AS "c0" WHERE "c0"."CustomerID" LIKE 'F%' ORDER BY "c0"."City" @@ -832,7 +832,7 @@ public override async Task Update_Where_OrderBy_Skip_Take_set_constant(bool asyn UPDATE "Customers" AS "c" SET "ContactName" = 'Updated' FROM ( - SELECT "c0"."CustomerID", "c0"."Address", "c0"."City", "c0"."CompanyName", "c0"."ContactName", "c0"."ContactTitle", "c0"."Country", "c0"."Fax", "c0"."Phone", "c0"."PostalCode", "c0"."Region" + SELECT "c0"."CustomerID" FROM "Customers" AS "c0" WHERE "c0"."CustomerID" LIKE 'F%' ORDER BY "c0"."City" @@ -854,9 +854,9 @@ public override async Task Update_Where_OrderBy_Skip_Take_Skip_Take_set_constant UPDATE "Customers" AS "c" SET "ContactName" = 'Updated' FROM ( - SELECT "t"."CustomerID", "t"."Address", "t"."City", "t"."CompanyName", "t"."ContactName", "t"."ContactTitle", "t"."Country", "t"."Fax", "t"."Phone", "t"."PostalCode", "t"."Region" + SELECT "t"."CustomerID" FROM ( - SELECT "c0"."CustomerID", "c0"."Address", "c0"."City", "c0"."CompanyName", "c0"."ContactName", "c0"."ContactTitle", "c0"."Country", "c0"."Fax", "c0"."Phone", "c0"."PostalCode", "c0"."Region" + SELECT "c0"."CustomerID", "c0"."City" FROM "Customers" AS "c0" WHERE "c0"."CustomerID" LIKE 'F%' ORDER BY "c0"."City" @@ -962,7 +962,7 @@ public override async Task Update_Where_using_navigation_set_null(bool async) UPDATE "Orders" AS "o" SET "OrderDate" = NULL FROM ( - SELECT "o0"."OrderID", "o0"."CustomerID", "o0"."EmployeeID", "o0"."OrderDate", "c"."CustomerID" AS "CustomerID0" + SELECT "o0"."OrderID" FROM "Orders" AS "o0" LEFT JOIN "Customers" AS "c" ON "o0"."CustomerID" = "c"."CustomerID" WHERE "c"."City" = 'Seattle' @@ -1140,11 +1140,11 @@ public override async Task Update_Concat_set_constant(bool async) UPDATE "Customers" AS "c" SET "ContactName" = 'Updated' FROM ( - SELECT "c0"."CustomerID", "c0"."Address", "c0"."City", "c0"."CompanyName", "c0"."ContactName", "c0"."ContactTitle", "c0"."Country", "c0"."Fax", "c0"."Phone", "c0"."PostalCode", "c0"."Region" + SELECT "c0"."CustomerID" FROM "Customers" AS "c0" WHERE "c0"."CustomerID" LIKE 'F%' UNION ALL - SELECT "c1"."CustomerID", "c1"."Address", "c1"."City", "c1"."CompanyName", "c1"."ContactName", "c1"."ContactTitle", "c1"."Country", "c1"."Fax", "c1"."Phone", "c1"."PostalCode", "c1"."Region" + SELECT "c1"."CustomerID" FROM "Customers" AS "c1" WHERE "c1"."CustomerID" LIKE 'A%' ) AS "t" @@ -1203,7 +1203,7 @@ public override async Task Update_with_join_set_constant(bool async) UPDATE "Customers" AS "c" SET "ContactName" = 'Updated' FROM ( - SELECT "o"."OrderID", "o"."CustomerID", "o"."EmployeeID", "o"."OrderDate" + SELECT "o"."CustomerID" FROM "Orders" AS "o" WHERE "o"."OrderID" < 10300 ) AS "t" @@ -1220,10 +1220,10 @@ public override async Task Update_with_left_join_set_constant(bool async) UPDATE "Customers" AS "c" SET "ContactName" = 'Updated' FROM ( - SELECT "c0"."CustomerID", "c0"."Address", "c0"."City", "c0"."CompanyName", "c0"."ContactName", "c0"."ContactTitle", "c0"."Country", "c0"."Fax", "c0"."Phone", "c0"."PostalCode", "c0"."Region", "t"."OrderID", "t"."CustomerID" AS "CustomerID0", "t"."EmployeeID", "t"."OrderDate" + SELECT "c0"."CustomerID" FROM "Customers" AS "c0" LEFT JOIN ( - SELECT "o"."OrderID", "o"."CustomerID", "o"."EmployeeID", "o"."OrderDate" + SELECT "o"."CustomerID" FROM "Orders" AS "o" WHERE "o"."OrderID" < 10300 ) AS "t" ON "c0"."CustomerID" = "t"."CustomerID" @@ -1242,7 +1242,7 @@ public override async Task Update_with_cross_join_set_constant(bool async) UPDATE "Customers" AS "c" SET "ContactName" = 'Updated' FROM ( - SELECT "o"."OrderID", "o"."CustomerID", "o"."EmployeeID", "o"."OrderDate" + SELECT 1 FROM "Orders" AS "o" WHERE "o"."OrderID" < 10300 ) AS "t" @@ -1311,10 +1311,10 @@ public override async Task Update_Where_SelectMany_subquery_set_null(bool async) UPDATE "Orders" AS "o" SET "OrderDate" = NULL FROM ( - SELECT "t"."OrderID", "t"."CustomerID", "t"."EmployeeID", "t"."OrderDate", "c"."CustomerID" AS "CustomerID0" + SELECT "t"."OrderID" FROM "Customers" AS "c" INNER JOIN ( - SELECT "o0"."OrderID", "o0"."CustomerID", "o0"."EmployeeID", "o0"."OrderDate" + SELECT "o0"."OrderID", "o0"."CustomerID" FROM "Orders" AS "o0" WHERE CAST(strftime('%Y', "o0"."OrderDate") AS INTEGER) = 1997 ) AS "t" ON "c"."CustomerID" = "t"."CustomerID" @@ -1350,7 +1350,7 @@ public override async Task Update_Where_Join_set_property_from_joined_table(bool UPDATE "Customers" AS "c" SET "City" = "t"."City" FROM ( - SELECT "c0"."CustomerID", "c0"."Address", "c0"."City", "c0"."CompanyName", "c0"."ContactName", "c0"."ContactTitle", "c0"."Country", "c0"."Fax", "c0"."Phone", "c0"."PostalCode", "c0"."Region" + SELECT "c0"."City" FROM "Customers" AS "c0" WHERE "c0"."CustomerID" = 'ALFKI' ) AS "t" diff --git a/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesSqliteTest.cs index de08dd35e1d..c6d5229ecf8 100644 --- a/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesSqliteTest.cs @@ -45,10 +45,10 @@ DELETE FROM "Countries" AS "c" WHERE ( SELECT COUNT(*) FROM ( - SELECT "e"."Id", "e"."CountryId", "e"."Name", "e"."Species", "e"."EagleId", "e"."IsFlightless", "e"."Group", NULL AS "FoundOn", 'Eagle' AS "Discriminator" + SELECT "e"."CountryId" FROM "Eagle" AS "e" UNION ALL - SELECT "k"."Id", "k"."CountryId", "k"."Name", "k"."Species", "k"."EagleId", "k"."IsFlightless", NULL AS "Group", "k"."FoundOn", 'Kiwi' AS "Discriminator" + SELECT "k"."CountryId" FROM "Kiwi" AS "k" ) AS "t" WHERE "t"."CountryId" = 1 AND "c"."Id" = "t"."CountryId" AND "t"."CountryId" > 0) > 0 @@ -65,7 +65,7 @@ DELETE FROM "Countries" AS "c" WHERE ( SELECT COUNT(*) FROM ( - SELECT "k"."Id", "k"."CountryId", "k"."Name", "k"."Species", "k"."EagleId", "k"."IsFlightless", NULL AS "Group", "k"."FoundOn", 'Kiwi' AS "Discriminator" + SELECT "k"."CountryId" FROM "Kiwi" AS "k" ) AS "t" WHERE "t"."CountryId" = 1 AND "c"."Id" = "t"."CountryId" AND "t"."CountryId" > 0) > 0 @@ -163,10 +163,10 @@ public override async Task Update_where_using_hierarchy(bool async) WHERE ( SELECT COUNT(*) FROM ( - SELECT "e"."Id", "e"."CountryId", "e"."Name", "e"."Species", "e"."EagleId", "e"."IsFlightless", "e"."Group", NULL AS "FoundOn", 'Eagle' AS "Discriminator" + SELECT "e"."CountryId" FROM "Eagle" AS "e" UNION ALL - SELECT "k"."Id", "k"."CountryId", "k"."Name", "k"."Species", "k"."EagleId", "k"."IsFlightless", NULL AS "Group", "k"."FoundOn", 'Kiwi' AS "Discriminator" + SELECT "k"."CountryId" FROM "Kiwi" AS "k" ) AS "t" WHERE "t"."CountryId" = 1 AND "c"."Id" = "t"."CountryId" AND "t"."CountryId" > 0) > 0 @@ -197,7 +197,7 @@ public override async Task Update_where_using_hierarchy_derived(bool async) WHERE ( SELECT COUNT(*) FROM ( - SELECT "k"."Id", "k"."CountryId", "k"."Name", "k"."Species", "k"."EagleId", "k"."IsFlightless", NULL AS "Group", "k"."FoundOn", 'Kiwi' AS "Discriminator" + SELECT "k"."CountryId" FROM "Kiwi" AS "k" ) AS "t" WHERE "t"."CountryId" = 1 AND "c"."Id" = "t"."CountryId" AND "t"."CountryId" > 0) > 0 diff --git a/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesSqliteTest.cs index fe71e85e3b8..54356bd35b8 100644 --- a/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesSqliteTest.cs @@ -44,10 +44,10 @@ DELETE FROM "Countries" AS "c" WHERE ( SELECT COUNT(*) FROM ( - SELECT "e"."Id", "e"."CountryId", "e"."Name", "e"."Species", "e"."EagleId", "e"."IsFlightless", "e"."Group", NULL AS "FoundOn", 'Eagle' AS "Discriminator" + SELECT "e"."CountryId" FROM "Eagle" AS "e" UNION ALL - SELECT "k"."Id", "k"."CountryId", "k"."Name", "k"."Species", "k"."EagleId", "k"."IsFlightless", NULL AS "Group", "k"."FoundOn", 'Kiwi' AS "Discriminator" + SELECT "k"."CountryId" FROM "Kiwi" AS "k" ) AS "t" WHERE "c"."Id" = "t"."CountryId" AND "t"."CountryId" > 0) > 0 @@ -64,7 +64,7 @@ DELETE FROM "Countries" AS "c" WHERE ( SELECT COUNT(*) FROM ( - SELECT "k"."Id", "k"."CountryId", "k"."Name", "k"."Species", "k"."EagleId", "k"."IsFlightless", NULL AS "Group", "k"."FoundOn", 'Kiwi' AS "Discriminator" + SELECT "k"."CountryId" FROM "Kiwi" AS "k" ) AS "t" WHERE "c"."Id" = "t"."CountryId" AND "t"."CountryId" > 0) > 0 @@ -160,10 +160,10 @@ public override async Task Update_where_using_hierarchy(bool async) WHERE ( SELECT COUNT(*) FROM ( - SELECT "e"."Id", "e"."CountryId", "e"."Name", "e"."Species", "e"."EagleId", "e"."IsFlightless", "e"."Group", NULL AS "FoundOn", 'Eagle' AS "Discriminator" + SELECT "e"."CountryId" FROM "Eagle" AS "e" UNION ALL - SELECT "k"."Id", "k"."CountryId", "k"."Name", "k"."Species", "k"."EagleId", "k"."IsFlightless", NULL AS "Group", "k"."FoundOn", 'Kiwi' AS "Discriminator" + SELECT "k"."CountryId" FROM "Kiwi" AS "k" ) AS "t" WHERE "c"."Id" = "t"."CountryId" AND "t"."CountryId" > 0) > 0 @@ -193,7 +193,7 @@ public override async Task Update_where_using_hierarchy_derived(bool async) WHERE ( SELECT COUNT(*) FROM ( - SELECT "k"."Id", "k"."CountryId", "k"."Name", "k"."Species", "k"."EagleId", "k"."IsFlightless", NULL AS "Group", "k"."FoundOn", 'Kiwi' AS "Discriminator" + SELECT "k"."CountryId" FROM "Kiwi" AS "k" ) AS "t" WHERE "c"."Id" = "t"."CountryId" AND "t"."CountryId" > 0) > 0 diff --git a/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesSqliteTest.cs index b3d260258cd..33d693ba0a4 100644 --- a/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesSqliteTest.cs @@ -43,9 +43,6 @@ DELETE FROM "Countries" AS "c" WHERE ( SELECT COUNT(*) FROM "Animals" AS "a" - LEFT JOIN "Birds" AS "b" ON "a"."Id" = "b"."Id" - LEFT JOIN "Eagle" AS "e" ON "a"."Id" = "e"."Id" - LEFT JOIN "Kiwi" AS "k" ON "a"."Id" = "k"."Id" WHERE "a"."CountryId" = 1 AND "c"."Id" = "a"."CountryId" AND "a"."CountryId" > 0) > 0 """); } @@ -60,8 +57,6 @@ DELETE FROM "Countries" AS "c" WHERE ( SELECT COUNT(*) FROM "Animals" AS "a" - LEFT JOIN "Birds" AS "b" ON "a"."Id" = "b"."Id" - LEFT JOIN "Eagle" AS "e" ON "a"."Id" = "e"."Id" LEFT JOIN "Kiwi" AS "k" ON "a"."Id" = "k"."Id" WHERE "a"."CountryId" = 1 AND "c"."Id" = "a"."CountryId" AND "k"."Id" IS NOT NULL AND "a"."CountryId" > 0) > 0 """); @@ -111,14 +106,8 @@ public override async Task Update_base_type(bool async) UPDATE "Animals" AS "a" SET "Name" = 'Animal' FROM ( - SELECT "a0"."Id", "a0"."CountryId", "a0"."Name", "a0"."Species", "b0"."EagleId", "b0"."IsFlightless", "e0"."Group", "k0"."FoundOn", CASE - WHEN "k0"."Id" IS NOT NULL THEN 'Kiwi' - WHEN "e0"."Id" IS NOT NULL THEN 'Eagle' - END AS "Discriminator" + SELECT "a0"."Id" FROM "Animals" AS "a0" - LEFT JOIN "Birds" AS "b0" ON "a0"."Id" = "b0"."Id" - LEFT JOIN "Eagle" AS "e0" ON "a0"."Id" = "e0"."Id" - LEFT JOIN "Kiwi" AS "k0" ON "a0"."Id" = "k0"."Id" WHERE "a0"."CountryId" = 1 AND "a0"."Name" = 'Great spotted kiwi' ) AS "t" WHERE "a"."Id" = "t"."Id" @@ -165,9 +154,6 @@ public override async Task Update_where_using_hierarchy(bool async) WHERE ( SELECT COUNT(*) FROM "Animals" AS "a" - LEFT JOIN "Birds" AS "b" ON "a"."Id" = "b"."Id" - LEFT JOIN "Eagle" AS "e" ON "a"."Id" = "e"."Id" - LEFT JOIN "Kiwi" AS "k" ON "a"."Id" = "k"."Id" WHERE "a"."CountryId" = 1 AND "c"."Id" = "a"."CountryId" AND "a"."CountryId" > 0) > 0 """); } @@ -190,8 +176,6 @@ public override async Task Update_where_using_hierarchy_derived(bool async) WHERE ( SELECT COUNT(*) FROM "Animals" AS "a" - LEFT JOIN "Birds" AS "b" ON "a"."Id" = "b"."Id" - LEFT JOIN "Eagle" AS "e" ON "a"."Id" = "e"."Id" LEFT JOIN "Kiwi" AS "k" ON "a"."Id" = "k"."Id" WHERE "a"."CountryId" = 1 AND "c"."Id" = "a"."CountryId" AND "k"."Id" IS NOT NULL AND "a"."CountryId" > 0) > 0 """); diff --git a/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesSqliteTest.cs index f0436eafe1b..b056aac6b8d 100644 --- a/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesSqliteTest.cs @@ -90,14 +90,8 @@ public override async Task Update_base_type(bool async) UPDATE "Animals" AS "a" SET "Name" = 'Animal' FROM ( - SELECT "a0"."Id", "a0"."CountryId", "a0"."Name", "a0"."Species", "b0"."EagleId", "b0"."IsFlightless", "e0"."Group", "k0"."FoundOn", CASE - WHEN "k0"."Id" IS NOT NULL THEN 'Kiwi' - WHEN "e0"."Id" IS NOT NULL THEN 'Eagle' - END AS "Discriminator" + SELECT "a0"."Id" FROM "Animals" AS "a0" - LEFT JOIN "Birds" AS "b0" ON "a0"."Id" = "b0"."Id" - LEFT JOIN "Eagle" AS "e0" ON "a0"."Id" = "e0"."Id" - LEFT JOIN "Kiwi" AS "k0" ON "a0"."Id" = "k0"."Id" WHERE "a0"."Name" = 'Great spotted kiwi' ) AS "t" WHERE "a"."Id" = "t"."Id" @@ -144,9 +138,6 @@ public override async Task Update_where_using_hierarchy(bool async) WHERE ( SELECT COUNT(*) FROM "Animals" AS "a" - LEFT JOIN "Birds" AS "b" ON "a"."Id" = "b"."Id" - LEFT JOIN "Eagle" AS "e" ON "a"."Id" = "e"."Id" - LEFT JOIN "Kiwi" AS "k" ON "a"."Id" = "k"."Id" WHERE "c"."Id" = "a"."CountryId" AND "a"."CountryId" > 0) > 0 """); } @@ -169,8 +160,6 @@ public override async Task Update_where_using_hierarchy_derived(bool async) WHERE ( SELECT COUNT(*) FROM "Animals" AS "a" - LEFT JOIN "Birds" AS "b" ON "a"."Id" = "b"."Id" - LEFT JOIN "Eagle" AS "e" ON "a"."Id" = "e"."Id" LEFT JOIN "Kiwi" AS "k" ON "a"."Id" = "k"."Id" WHERE "c"."Id" = "a"."CountryId" AND "k"."Id" IS NOT NULL AND "a"."CountryId" > 0) > 0 """); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs index b22dba28e0b..9cb95acc004 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs @@ -1261,11 +1261,11 @@ public override async Task Where_subquery_concat_firstordefault_boolean(bool asy WHERE "g"."HasSoulPatch" AND ( SELECT "t"."IsAutomatic" FROM ( - SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" + SELECT "w"."Id", "w"."IsAutomatic" FROM "Weapons" AS "w" WHERE "g"."FullName" = "w"."OwnerFullName" UNION ALL - SELECT "w0"."Id", "w0"."AmmunitionType", "w0"."IsAutomatic", "w0"."Name", "w0"."OwnerFullName", "w0"."SynergyWithId" + SELECT "w0"."Id", "w0"."IsAutomatic" FROM "Weapons" AS "w0" WHERE "g"."FullName" = "w0"."OwnerFullName" ) AS "t" @@ -3568,10 +3568,10 @@ public override async Task Concat_with_count(bool async) """ SELECT COUNT(*) FROM ( - SELECT "g"."Nickname", "g"."SquadId", "g"."AssignedCityName", "g"."CityOfBirthName", "g"."Discriminator", "g"."FullName", "g"."HasSoulPatch", "g"."LeaderNickname", "g"."LeaderSquadId", "g"."Rank" + SELECT 1 FROM "Gears" AS "g" UNION ALL - SELECT "g0"."Nickname", "g0"."SquadId", "g0"."AssignedCityName", "g0"."CityOfBirthName", "g0"."Discriminator", "g0"."FullName", "g0"."HasSoulPatch", "g0"."LeaderNickname", "g0"."LeaderSquadId", "g0"."Rank" + SELECT 1 FROM "Gears" AS "g0" ) AS "t" """); @@ -4453,11 +4453,11 @@ public override async Task Select_navigation_with_concat_and_count(bool async) SELECT ( SELECT COUNT(*) FROM ( - SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" + SELECT 1 FROM "Weapons" AS "w" WHERE "g"."FullName" = "w"."OwnerFullName" UNION ALL - SELECT "w0"."Id", "w0"."AmmunitionType", "w0"."IsAutomatic", "w0"."Name", "w0"."OwnerFullName", "w0"."SynergyWithId" + SELECT 1 FROM "Weapons" AS "w0" WHERE "g"."FullName" = "w0"."OwnerFullName" ) AS "t") @@ -5129,10 +5129,10 @@ public override async Task Concat_anonymous_with_count(bool async) """ SELECT COUNT(*) FROM ( - SELECT "g"."Nickname", "g"."SquadId", "g"."AssignedCityName", "g"."CityOfBirthName", "g"."Discriminator", "g"."FullName", "g"."HasSoulPatch", "g"."LeaderNickname", "g"."LeaderSquadId", "g"."Rank", "g"."Nickname" AS "Name" + SELECT 1 FROM "Gears" AS "g" UNION ALL - SELECT "g0"."Nickname", "g0"."SquadId", "g0"."AssignedCityName", "g0"."CityOfBirthName", "g0"."Discriminator", "g0"."FullName", "g0"."HasSoulPatch", "g0"."LeaderNickname", "g0"."LeaderSquadId", "g0"."Rank", "g0"."FullName" AS "Name" + SELECT 1 FROM "Gears" AS "g0" ) AS "t" """); @@ -5438,7 +5438,7 @@ public override async Task Where_subquery_join_firstordefault_boolean(bool async SELECT "w"."IsAutomatic" FROM "Weapons" AS "w" INNER JOIN ( - SELECT "w0"."Id", "w0"."AmmunitionType", "w0"."IsAutomatic", "w0"."Name", "w0"."OwnerFullName", "w0"."SynergyWithId" + SELECT "w0"."Id" FROM "Weapons" AS "w0" WHERE "g"."FullName" = "w0"."OwnerFullName" ) AS "t" ON "w"."Id" = "t"."Id" @@ -5890,7 +5890,7 @@ public override async Task Where_subquery_left_join_firstordefault_boolean(bool SELECT "w"."IsAutomatic" FROM "Weapons" AS "w" LEFT JOIN ( - SELECT "w0"."Id", "w0"."AmmunitionType", "w0"."IsAutomatic", "w0"."Name", "w0"."OwnerFullName", "w0"."SynergyWithId" + SELECT "w0"."Id" FROM "Weapons" AS "w0" WHERE "g"."FullName" = "w0"."OwnerFullName" ) AS "t" ON "w"."Id" = "t"."Id" @@ -8304,10 +8304,10 @@ public override async Task Concat_scalars_with_count(bool async) """ SELECT COUNT(*) FROM ( - SELECT "g"."Nickname" + SELECT 1 FROM "Gears" AS "g" UNION ALL - SELECT "g0"."FullName" AS "Nickname" + SELECT 1 FROM "Gears" AS "g0" ) AS "t" """); @@ -9495,26 +9495,20 @@ SELECT COALESCE(SUM(length("c"."Location")), 0) INNER JOIN "Squads" AS "s0" ON "g2"."SquadId" = "s0"."Id" INNER JOIN "Cities" AS "c" ON "g2"."CityOfBirthName" = "c"."Name" WHERE 'Marcus' IN ( - SELECT "t0"."Nickname" - FROM ( - SELECT "g3"."Nickname", "g3"."SquadId", "g3"."AssignedCityName", "g3"."CityOfBirthName", "g3"."Discriminator", "g3"."FullName", "g3"."HasSoulPatch", "g3"."LeaderNickname", "g3"."LeaderSquadId", "g3"."Rank" - FROM "Gears" AS "g3" - UNION ALL - SELECT "g4"."Nickname", "g4"."SquadId", "g4"."AssignedCityName", "g4"."CityOfBirthName", "g4"."Discriminator", "g4"."FullName", "g4"."HasSoulPatch", "g4"."LeaderNickname", "g4"."LeaderSquadId", "g4"."Rank" - FROM "Gears" AS "g4" - ) AS "t0" + SELECT "g3"."Nickname" + FROM "Gears" AS "g3" + UNION ALL + SELECT "g4"."Nickname" + FROM "Gears" AS "g4" ) AND ("s"."Name" = "s0"."Name" OR ("s"."Name" IS NULL AND "s0"."Name" IS NULL))) AS "SumOfLengths" FROM "Gears" AS "g" INNER JOIN "Squads" AS "s" ON "g"."SquadId" = "s"."Id" WHERE 'Marcus' IN ( - SELECT "t"."Nickname" - FROM ( - SELECT "g0"."Nickname", "g0"."SquadId", "g0"."AssignedCityName", "g0"."CityOfBirthName", "g0"."Discriminator", "g0"."FullName", "g0"."HasSoulPatch", "g0"."LeaderNickname", "g0"."LeaderSquadId", "g0"."Rank" - FROM "Gears" AS "g0" - UNION ALL - SELECT "g1"."Nickname", "g1"."SquadId", "g1"."AssignedCityName", "g1"."CityOfBirthName", "g1"."Discriminator", "g1"."FullName", "g1"."HasSoulPatch", "g1"."LeaderNickname", "g1"."LeaderSquadId", "g1"."Rank" - FROM "Gears" AS "g1" - ) AS "t" + SELECT "g0"."Nickname" + FROM "Gears" AS "g0" + UNION ALL + SELECT "g1"."Nickname" + FROM "Gears" AS "g1" ) GROUP BY "s"."Name" """); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/JsonQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/JsonQuerySqliteTest.cs index d0bcd5a9a26..b2348748ad6 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/JsonQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/JsonQuerySqliteTest.cs @@ -78,7 +78,7 @@ public override async Task Json_collection_Any_with_predicate(bool async) WHERE EXISTS ( SELECT 1 FROM ( - SELECT "o"."value" ->> 'Date' AS "Date", "o"."value" ->> 'Enum' AS "Enum", "o"."value" ->> 'Enums' AS "Enums", "o"."value" ->> 'Fraction' AS "Fraction", "o"."value" ->> 'NullableEnum' AS "NullableEnum", "o"."value" ->> 'NullableEnums' AS "NullableEnums", "o"."value" ->> 'OwnedCollectionLeaf' AS "OwnedCollectionLeaf", "o"."value" ->> 'OwnedReferenceLeaf' AS "OwnedReferenceLeaf", "o"."key" + SELECT "o"."value" ->> 'OwnedReferenceLeaf' AS "OwnedReferenceLeaf" FROM json_each("j"."OwnedReferenceRoot", '$.OwnedCollectionBranch') AS "o" ) AS "t" WHERE "t"."OwnedReferenceLeaf" ->> 'SomethingSomething' = 'e1_r_c1_r') @@ -96,7 +96,7 @@ public override async Task Json_collection_Where_ElementAt(bool async) WHERE ( SELECT "t"."OwnedReferenceLeaf" ->> 'SomethingSomething' FROM ( - SELECT "o"."value" ->> 'Date' AS "Date", "o"."value" ->> 'Enum' AS "Enum", "o"."value" ->> 'Enums' AS "Enums", "o"."value" ->> 'Fraction' AS "Fraction", "o"."value" ->> 'NullableEnum' AS "NullableEnum", "o"."value" ->> 'NullableEnums' AS "NullableEnums", "o"."value" ->> 'OwnedCollectionLeaf' AS "OwnedCollectionLeaf", "o"."value" ->> 'OwnedReferenceLeaf' AS "OwnedReferenceLeaf", "o"."key" + SELECT "o"."value" ->> 'Date' AS "Date", "o"."value" ->> 'Enum' AS "Enum", "o"."value" ->> 'Fraction' AS "Fraction", "o"."value" ->> 'OwnedReferenceLeaf' AS "OwnedReferenceLeaf", "o"."key" FROM json_each("j"."OwnedReferenceRoot", '$.OwnedCollectionBranch') AS "o" ) AS "t" WHERE "t"."Enum" = 2 @@ -116,9 +116,9 @@ public override async Task Json_collection_Skip(bool async) WHERE ( SELECT "t0"."c" FROM ( - SELECT "t"."OwnedReferenceLeaf" ->> 'SomethingSomething' AS "c", "t"."key", "t"."key" AS "key0" + SELECT "t"."OwnedReferenceLeaf" ->> 'SomethingSomething' AS "c", "t"."key" AS "key0" FROM ( - SELECT "o"."value" ->> 'Date' AS "Date", "o"."value" ->> 'Enum' AS "Enum", "o"."value" ->> 'Enums' AS "Enums", "o"."value" ->> 'Fraction' AS "Fraction", "o"."value" ->> 'NullableEnum' AS "NullableEnum", "o"."value" ->> 'NullableEnums' AS "NullableEnums", "o"."value" ->> 'OwnedCollectionLeaf' AS "OwnedCollectionLeaf", "o"."value" ->> 'OwnedReferenceLeaf' AS "OwnedReferenceLeaf", "o"."key" + SELECT "o"."value" ->> 'OwnedReferenceLeaf' AS "OwnedReferenceLeaf", "o"."key" FROM json_each("j"."OwnedReferenceRoot", '$.OwnedCollectionBranch') AS "o" ) AS "t" ORDER BY "t"."key" @@ -140,9 +140,9 @@ public override async Task Json_collection_OrderByDescending_Skip_ElementAt(bool WHERE ( SELECT "t0"."c" FROM ( - SELECT "t"."OwnedReferenceLeaf" ->> 'SomethingSomething' AS "c", "t"."key", "t"."Date" AS "c0" + SELECT "t"."OwnedReferenceLeaf" ->> 'SomethingSomething' AS "c", "t"."Date" AS "c0" FROM ( - SELECT "o"."value" ->> 'Date' AS "Date", "o"."value" ->> 'Enum' AS "Enum", "o"."value" ->> 'Enums' AS "Enums", "o"."value" ->> 'Fraction' AS "Fraction", "o"."value" ->> 'NullableEnum' AS "NullableEnum", "o"."value" ->> 'NullableEnums' AS "NullableEnums", "o"."value" ->> 'OwnedCollectionLeaf' AS "OwnedCollectionLeaf", "o"."value" ->> 'OwnedReferenceLeaf' AS "OwnedReferenceLeaf", "o"."key" + SELECT "o"."value" ->> 'Date' AS "Date", "o"."value" ->> 'Enum' AS "Enum", "o"."value" ->> 'Fraction' AS "Fraction", "o"."value" ->> 'OwnedReferenceLeaf' AS "OwnedReferenceLeaf" FROM json_each("j"."OwnedReferenceRoot", '$.OwnedCollectionBranch') AS "o" ) AS "t" ORDER BY "t"."Date" DESC @@ -164,13 +164,13 @@ public override async Task Json_collection_within_collection_Count(bool async) WHERE EXISTS ( SELECT 1 FROM ( - SELECT "o"."value" ->> 'Name' AS "Name", "o"."value" ->> 'Names' AS "Names", "o"."value" ->> 'Number' AS "Number", "o"."value" ->> 'Numbers' AS "Numbers", "o"."value" ->> 'OwnedCollectionBranch' AS "OwnedCollectionBranch", "o"."value" ->> 'OwnedReferenceBranch' AS "OwnedReferenceBranch", "o"."key" + SELECT "o"."value" ->> 'OwnedCollectionBranch' AS "OwnedCollectionBranch" FROM json_each("j"."OwnedCollectionRoot", '$') AS "o" ) AS "t" WHERE ( SELECT COUNT(*) FROM ( - SELECT "o0"."value" ->> 'Date' AS "Date", "o0"."value" ->> 'Enum' AS "Enum", "o0"."value" ->> 'Enums' AS "Enums", "o0"."value" ->> 'Fraction' AS "Fraction", "o0"."value" ->> 'NullableEnum' AS "NullableEnum", "o0"."value" ->> 'NullableEnums' AS "NullableEnums", "o0"."value" ->> 'OwnedCollectionLeaf' AS "OwnedCollectionLeaf", "o0"."value" ->> 'OwnedReferenceLeaf' AS "OwnedReferenceLeaf", "o0"."key" + SELECT 1 FROM json_each("t"."OwnedCollectionBranch", '$') AS "o0" ) AS "t0") = 2) """); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs index c0cf5800c75..4605e5370ce 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs @@ -255,7 +255,7 @@ public override async Task Select_orderBy_skip_long_count(bool async) SELECT COUNT(*) FROM ( - SELECT "c"."CustomerID" + SELECT 1 FROM "Customers" AS "c" ORDER BY "c"."Country" LIMIT -1 OFFSET @__p_0 @@ -273,7 +273,7 @@ public override async Task Select_orderBy_take_long_count(bool async) SELECT COUNT(*) FROM ( - SELECT "c"."CustomerID" + SELECT 1 FROM "Customers" AS "c" ORDER BY "c"."Country" LIMIT @__p_0 @@ -291,7 +291,7 @@ public override async Task Select_skip_long_count(bool async) SELECT COUNT(*) FROM ( - SELECT "c"."CustomerID" + SELECT 1 FROM "Customers" AS "c" LIMIT -1 OFFSET @__p_0 ) AS "t" @@ -308,7 +308,7 @@ public override async Task Select_take_long_count(bool async) SELECT COUNT(*) FROM ( - SELECT "c"."CustomerID" + SELECT 1 FROM "Customers" AS "c" LIMIT @__p_0 ) AS "t" diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/PrimitiveCollectionsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/PrimitiveCollectionsQuerySqliteTest.cs index a426d3525d8..e4a6ac772ef 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/PrimitiveCollectionsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/PrimitiveCollectionsQuerySqliteTest.cs @@ -703,7 +703,7 @@ public override async Task Column_collection_Skip(bool async) WHERE ( SELECT COUNT(*) FROM ( - SELECT "i"."key" + SELECT 1 FROM json_each("p"."Ints") AS "i" ORDER BY "i"."key" LIMIT -1 OFFSET 1 @@ -856,10 +856,10 @@ await Assert.ThrowsAsync( WHERE ( SELECT COUNT(*) FROM ( - SELECT "i"."value" + SELECT 1 FROM json_each(@__ints_0) AS "i" UNION ALL - SELECT "i0"."value" + SELECT 1 FROM json_each("p"."Ints") AS "i0" ) AS "t") = 2 """); @@ -979,7 +979,7 @@ SELECT COUNT(*) WHERE ( SELECT COUNT(*) FROM ( - SELECT "i"."value", "i"."key", "i"."value" AS "value0" + SELECT "i"."value" AS "value0" FROM json_each(@__ints) AS "i" ORDER BY "i"."key" LIMIT -1 OFFSET 1 @@ -1010,7 +1010,7 @@ SELECT COUNT(*) FROM ( SELECT "t"."value" FROM ( - SELECT "i"."value", "i"."key" + SELECT "i"."value" FROM json_each(@__ints) AS "i" ORDER BY "i"."key" LIMIT -1 OFFSET 1 @@ -1066,7 +1066,7 @@ FROM json_each(@__Skip_0) AS "s" FROM ( SELECT DISTINCT "t2"."value" FROM ( - SELECT "i"."value", "i"."key" + SELECT "i"."value" FROM json_each("p"."Ints") AS "i" ORDER BY "i"."value" LIMIT -1 OFFSET 1 @@ -1101,7 +1101,7 @@ SELECT COUNT(*) FROM ( SELECT "t"."value" FROM ( - SELECT "i"."value", "i"."key" + SELECT "i"."value" FROM json_each("p"."Ints") AS "i" ORDER BY "i"."key" LIMIT -1 OFFSET 1 diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPCGearsOfWarQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPCGearsOfWarQuerySqliteTest.cs index c0f4976a051..7f049471806 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPCGearsOfWarQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPCGearsOfWarQuerySqliteTest.cs @@ -373,10 +373,10 @@ public override async Task Where_subquery_with_ElementAt_using_column_as_index(b WHERE ( SELECT "t"."Nickname" FROM ( - SELECT "g"."Nickname", "g"."SquadId", "g"."AssignedCityName", "g"."CityOfBirthName", "g"."FullName", "g"."HasSoulPatch", "g"."LeaderNickname", "g"."LeaderSquadId", "g"."Rank", 'Gear' AS "Discriminator" + SELECT "g"."Nickname", "g"."SquadId" FROM "Gears" AS "g" UNION ALL - SELECT "o"."Nickname", "o"."SquadId", "o"."AssignedCityName", "o"."CityOfBirthName", "o"."FullName", "o"."HasSoulPatch", "o"."LeaderNickname", "o"."LeaderSquadId", "o"."Rank", 'Officer' AS "Discriminator" + SELECT "o"."Nickname", "o"."SquadId" FROM "Officers" AS "o" ) AS "t" WHERE "s"."Id" = "t"."SquadId" diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPTGearsOfWarQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPTGearsOfWarQuerySqliteTest.cs index fd99c211826..157c24d0869 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPTGearsOfWarQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPTGearsOfWarQuerySqliteTest.cs @@ -373,7 +373,6 @@ public override async Task Where_subquery_with_ElementAt_using_column_as_index(b WHERE ( SELECT "g"."Nickname" FROM "Gears" AS "g" - LEFT JOIN "Officers" AS "o" ON "g"."Nickname" = "o"."Nickname" AND "g"."SquadId" = "o"."SquadId" WHERE "s"."Id" = "g"."SquadId" ORDER BY "g"."Nickname" LIMIT 1 OFFSET "s"."Id") = 'Cole Train'