From d2964e17395e7a7242eeb3b793662bf6d24d37c1 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Mon, 18 Aug 2025 18:36:16 +0200 Subject: [PATCH] Complex type test fixes --- ...ingExpressionVisitor.StructuralEquality.cs | 11 +- .../OwnedNavigationsCollectionCosmosTest.cs | 2 +- .../OwnedNavigationsCosmosFixture.cs | 4 +- .../OwnedNavigationsRelationalFixtureBase.cs | 3 + ...wnedTableSplittingRelationalFixtureBase.cs | 3 + .../OwnedNavigationsFixtureBase.cs | 9 +- .../OwnedJsonCollectionSqlServerTest.cs | 2 +- ...OwnedNavigationsCollectionSqlServerTest.cs | 114 +----------------- .../OwnedNavigationsCollectionSqliteTest.cs | 4 - 9 files changed, 26 insertions(+), 126 deletions(-) diff --git a/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.StructuralEquality.cs b/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.StructuralEquality.cs index 9d8f54903b9..cfbf85177b4 100644 --- a/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.StructuralEquality.cs +++ b/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.StructuralEquality.cs @@ -320,7 +320,7 @@ bool TryRewriteComplexTypeEquality(bool collection, [NotNullWhen(true)] out SqlE var boolTypeMapping = Dependencies.TypeMappingSource.FindMapping(typeof(bool))!; SqlExpression? comparisons = null; - if (!TryGenerateComparisons(complexType, left, right, ref comparisons)) + if (!TryGenerateComparisons(complexType, left, right, ref comparisons, out _)) { result = null; return false; @@ -333,9 +333,7 @@ bool TryRewriteComplexTypeEquality(bool collection, [NotNullWhen(true)] out SqlE // into complex properties to generate a flattened list of comparisons. // The moment we reach a a complex property that's mapped to JSON, we stop and generate a single comparison // for the whole complex type. - bool TryGenerateComparisons(IComplexType complexType, Expression left, Expression right, [NotNullWhen(true)] ref SqlExpression? comparisons) - => TryGenerateComparisonsRec(complexType, left, right, ref comparisons, out _); - bool TryGenerateComparisonsRec(IComplexType type, Expression left, Expression right, [NotNullWhen(true)] ref SqlExpression? comparisons, out bool exitImmediately) + bool TryGenerateComparisons(IComplexType type, Expression left, Expression right, [NotNullWhen(true)] ref SqlExpression? comparisons, out bool exitImmediately) { exitImmediately = false; @@ -346,6 +344,9 @@ bool TryGenerateComparisonsRec(IComplexType type, Expression left, Expression ri var comparison = _sqlExpressionFactory.MakeBinary(nodeType, leftScalar, rightScalar, boolTypeMapping)!; + // A single JSON-mapped complex type requires only a single comparison for the JSON value/column on each side; + // but the JSON-mapped complex type may be nested inside a non-JSON (table-split) complex type, in which + // case this is just one comparison in several. comparisons = comparisons is null ? comparison : nodeType == ExpressionType.Equal @@ -458,7 +459,7 @@ SqlParameterExpression parameter if (nestedLeft is null || nestedRight is null - || !TryGenerateComparisonsRec(complexProperty.ComplexType, nestedLeft, nestedRight, ref comparisons, out exitImmediately)) + || !TryGenerateComparisons(complexProperty.ComplexType, nestedLeft, nestedRight, ref comparisons, out exitImmediately)) { return false; } diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/Relationships/OwnedNavigations/OwnedNavigationsCollectionCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/Relationships/OwnedNavigations/OwnedNavigationsCollectionCosmosTest.cs index c062ad03080..1c9556fda96 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/Relationships/OwnedNavigations/OwnedNavigationsCollectionCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/Relationships/OwnedNavigations/OwnedNavigationsCollectionCosmosTest.cs @@ -93,7 +93,7 @@ public override async Task Index_parameter() AssertSql( """ -@i=? +@i='0' SELECT VALUE c FROM root c diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/Relationships/OwnedNavigations/OwnedNavigationsCosmosFixture.cs b/test/EFCore.Cosmos.FunctionalTests/Query/Relationships/OwnedNavigations/OwnedNavigationsCosmosFixture.cs index 8859bea30aa..ffc9a3a4e31 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/Relationships/OwnedNavigations/OwnedNavigationsCosmosFixture.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/Relationships/OwnedNavigations/OwnedNavigationsCosmosFixture.cs @@ -12,8 +12,8 @@ protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) - => base.AddOptions( - builder.ConfigureWarnings(w => w.Ignore(CosmosEventId.NoPartitionKeyDefined))); + => base.AddOptions(builder) + .ConfigureWarnings(w => w.Ignore(CosmosEventId.NoPartitionKeyDefined)); public Task NoSyncTest(bool async, Func testCode) => CosmosTestHelpers.Instance.NoSyncTest(async, testCode); diff --git a/test/EFCore.Relational.Specification.Tests/Query/Relationships/OwnedNavigations/OwnedNavigationsRelationalFixtureBase.cs b/test/EFCore.Relational.Specification.Tests/Query/Relationships/OwnedNavigations/OwnedNavigationsRelationalFixtureBase.cs index 0e36c16360c..668e613c7fb 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/Relationships/OwnedNavigations/OwnedNavigationsRelationalFixtureBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/Relationships/OwnedNavigations/OwnedNavigationsRelationalFixtureBase.cs @@ -10,6 +10,9 @@ namespace Microsoft.EntityFrameworkCore.Query.Relationships.OwnedNavigations; /// public abstract class OwnedNavigationsRelationalFixtureBase : OwnedTableSplittingRelationalFixtureBase, ITestSqlLoggerFactory { + public override bool AreCollectionsOrdered + => false; + protected override string StoreName => "OwnedNavigationsQueryTest"; diff --git a/test/EFCore.Relational.Specification.Tests/Query/Relationships/OwnedTableSplitting/OwnedTableSplittingRelationalFixtureBase.cs b/test/EFCore.Relational.Specification.Tests/Query/Relationships/OwnedTableSplitting/OwnedTableSplittingRelationalFixtureBase.cs index 1155704a614..13a96578954 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/Relationships/OwnedTableSplitting/OwnedTableSplittingRelationalFixtureBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/Relationships/OwnedTableSplitting/OwnedTableSplittingRelationalFixtureBase.cs @@ -11,6 +11,9 @@ namespace Microsoft.EntityFrameworkCore.Query.Relationships.OwnedTableSplitting; /// public abstract class OwnedTableSplittingRelationalFixtureBase : OwnedNavigationsFixtureBase, ITestSqlLoggerFactory { + public override bool AreCollectionsOrdered + => false; + protected override string StoreName => "OwnedTableSplittingQueryTest"; diff --git a/test/EFCore.Specification.Tests/Query/Relationships/OwnedNavigations/OwnedNavigationsFixtureBase.cs b/test/EFCore.Specification.Tests/Query/Relationships/OwnedNavigations/OwnedNavigationsFixtureBase.cs index 3143c063549..2fac96c3613 100644 --- a/test/EFCore.Specification.Tests/Query/Relationships/OwnedNavigations/OwnedNavigationsFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/Relationships/OwnedNavigations/OwnedNavigationsFixtureBase.cs @@ -76,8 +76,11 @@ protected override RelationshipsData CreateData() return data; } - // Derived fixtures may need to ignore some owned navigations that are mapped in this fixture. public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) - => builder.ConfigureWarnings(b => - b.Default(WarningBehavior.Ignore).Log(CoreEventId.MappedNavigationIgnoredWarning)); + => base.AddOptions(builder) + .ConfigureWarnings(b => b + // Derived fixtures may need to ignore some owned navigations that are mapped in this fixture, + .Ignore(CoreEventId.MappedNavigationIgnoredWarning) + // Cosmos (and possibly others) don't support navigations, so we remove RootReferencingType from the model + .Ignore(CoreEventId.MappedEntityTypeIgnoredWarning)); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Relationships/OwnedJson/OwnedJsonCollectionSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Relationships/OwnedJson/OwnedJsonCollectionSqlServerTest.cs index 79b29fa54e0..ed5c4d9b45f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/Relationships/OwnedJson/OwnedJsonCollectionSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Relationships/OwnedJson/OwnedJsonCollectionSqlServerTest.cs @@ -151,7 +151,7 @@ public override async Task Index_parameter() AssertSql( """ -@i='?' (DbType = Int32) +@i='0' SELECT [r].[Id], [r].[Name], [r].[OptionalRelated], [r].[RelatedCollection], [r].[RequiredRelated] FROM [RootEntity] AS [r] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Relationships/OwnedNavigations/OwnedNavigationsCollectionSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Relationships/OwnedNavigations/OwnedNavigationsCollectionSqlServerTest.cs index 2afca7504b7..971e0820596 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/Relationships/OwnedNavigations/OwnedNavigationsCollectionSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Relationships/OwnedNavigations/OwnedNavigationsCollectionSqlServerTest.cs @@ -185,134 +185,28 @@ public override async Task Index_constant() { await base.Index_constant(); - AssertSql( - """ -SELECT [r].[Id], [r].[Name], [o].[RootEntityId], [o].[Id], [o].[Int], [o].[Name], [o].[String], [o0].[RelatedTypeRootEntityId], [o1].[RelatedTypeRootEntityId], [r1].[RootEntityId], [r2].[RelatedTypeRootEntityId], [r3].[RelatedTypeRootEntityId], [o2].[RelatedTypeRootEntityId], [o2].[Id], [o2].[Int], [o2].[Name], [o2].[String], [o0].[Id], [o0].[Int], [o0].[Name], [o0].[String], [o1].[Id], [o1].[Int], [o1].[Name], [o1].[String], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Name], [s].[String], [s].[RelatedTypeRootEntityId], [s].[RelatedTypeId], [s].[RelatedTypeRootEntityId0], [s].[RelatedTypeId0], [s].[RelatedTypeRootEntityId1], [s].[RelatedTypeId1], [s].[Id0], [s].[Int0], [s].[Name0], [s].[String0], [s].[Id1], [s].[Int1], [s].[Name1], [s].[String1], [s].[Id2], [s].[Int2], [s].[Name2], [s].[String2], [r1].[Id], [r1].[Int], [r1].[Name], [r1].[String], [r8].[RelatedTypeRootEntityId], [r8].[Id], [r8].[Int], [r8].[Name], [r8].[String], [r2].[Id], [r2].[Int], [r2].[Name], [r2].[String], [r3].[Id], [r3].[Int], [r3].[Name], [r3].[String] -FROM [RootEntity] AS [r] -LEFT JOIN [OptionalRelated] AS [o] ON [r].[Id] = [o].[RootEntityId] -LEFT JOIN [OptionalRelated_OptionalNested] AS [o0] ON [o].[RootEntityId] = [o0].[RelatedTypeRootEntityId] -LEFT JOIN [OptionalRelated_RequiredNested] AS [o1] ON [o].[RootEntityId] = [o1].[RelatedTypeRootEntityId] -LEFT JOIN [RequiredRelated] AS [r1] ON [r].[Id] = [r1].[RootEntityId] -LEFT JOIN [RequiredRelated_OptionalNested] AS [r2] ON [r1].[RootEntityId] = [r2].[RelatedTypeRootEntityId] -LEFT JOIN [RequiredRelated_RequiredNested] AS [r3] ON [r1].[RootEntityId] = [r3].[RelatedTypeRootEntityId] -LEFT JOIN [OptionalRelated_NestedCollection] AS [o2] ON [o].[RootEntityId] = [o2].[RelatedTypeRootEntityId] -LEFT JOIN ( - SELECT [r4].[RootEntityId], [r4].[Id], [r4].[Int], [r4].[Name], [r4].[String], [r5].[RelatedTypeRootEntityId], [r5].[RelatedTypeId], [r6].[RelatedTypeRootEntityId] AS [RelatedTypeRootEntityId0], [r6].[RelatedTypeId] AS [RelatedTypeId0], [r7].[RelatedTypeRootEntityId] AS [RelatedTypeRootEntityId1], [r7].[RelatedTypeId] AS [RelatedTypeId1], [r7].[Id] AS [Id0], [r7].[Int] AS [Int0], [r7].[Name] AS [Name0], [r7].[String] AS [String0], [r5].[Id] AS [Id1], [r5].[Int] AS [Int1], [r5].[Name] AS [Name1], [r5].[String] AS [String1], [r6].[Id] AS [Id2], [r6].[Int] AS [Int2], [r6].[Name] AS [Name2], [r6].[String] AS [String2] - FROM [RelatedCollection] AS [r4] - LEFT JOIN [RelatedCollection_OptionalNested] AS [r5] ON [r4].[RootEntityId] = [r5].[RelatedTypeRootEntityId] AND [r4].[Id] = [r5].[RelatedTypeId] - LEFT JOIN [RelatedCollection_RequiredNested] AS [r6] ON [r4].[RootEntityId] = [r6].[RelatedTypeRootEntityId] AND [r4].[Id] = [r6].[RelatedTypeId] - LEFT JOIN [RelatedCollection_NestedCollection] AS [r7] ON [r4].[RootEntityId] = [r7].[RelatedTypeRootEntityId] AND [r4].[Id] = [r7].[RelatedTypeId] -) AS [s] ON [r].[Id] = [s].[RootEntityId] -LEFT JOIN [RequiredRelated_NestedCollection] AS [r8] ON [r1].[RootEntityId] = [r8].[RelatedTypeRootEntityId] -WHERE ( - SELECT [r0].[Int] - FROM [RelatedCollection] AS [r0] - WHERE [r].[Id] = [r0].[RootEntityId] - ORDER BY (SELECT 1) - OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY) = 8 -ORDER BY [r].[Id], [o].[RootEntityId], [o0].[RelatedTypeRootEntityId], [o1].[RelatedTypeRootEntityId], [r1].[RootEntityId], [r2].[RelatedTypeRootEntityId], [r3].[RelatedTypeRootEntityId], [o2].[RelatedTypeRootEntityId], [o2].[Id], [s].[RootEntityId], [s].[Id], [s].[RelatedTypeRootEntityId], [s].[RelatedTypeId], [s].[RelatedTypeRootEntityId0], [s].[RelatedTypeId0], [s].[RelatedTypeRootEntityId1], [s].[RelatedTypeId1], [s].[Id0], [r8].[RelatedTypeRootEntityId] -"""); + AssertSql(); } public override async Task Index_parameter() { await base.Index_parameter(); - AssertSql( - """ -@i='?' (DbType = Int32) - -SELECT [r].[Id], [r].[Name], [o].[RootEntityId], [o].[Id], [o].[Int], [o].[Name], [o].[String], [o0].[RelatedTypeRootEntityId], [o1].[RelatedTypeRootEntityId], [r1].[RootEntityId], [r2].[RelatedTypeRootEntityId], [r3].[RelatedTypeRootEntityId], [o2].[RelatedTypeRootEntityId], [o2].[Id], [o2].[Int], [o2].[Name], [o2].[String], [o0].[Id], [o0].[Int], [o0].[Name], [o0].[String], [o1].[Id], [o1].[Int], [o1].[Name], [o1].[String], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Name], [s].[String], [s].[RelatedTypeRootEntityId], [s].[RelatedTypeId], [s].[RelatedTypeRootEntityId0], [s].[RelatedTypeId0], [s].[RelatedTypeRootEntityId1], [s].[RelatedTypeId1], [s].[Id0], [s].[Int0], [s].[Name0], [s].[String0], [s].[Id1], [s].[Int1], [s].[Name1], [s].[String1], [s].[Id2], [s].[Int2], [s].[Name2], [s].[String2], [r1].[Id], [r1].[Int], [r1].[Name], [r1].[String], [r8].[RelatedTypeRootEntityId], [r8].[Id], [r8].[Int], [r8].[Name], [r8].[String], [r2].[Id], [r2].[Int], [r2].[Name], [r2].[String], [r3].[Id], [r3].[Int], [r3].[Name], [r3].[String] -FROM [RootEntity] AS [r] -LEFT JOIN [OptionalRelated] AS [o] ON [r].[Id] = [o].[RootEntityId] -LEFT JOIN [OptionalRelated_OptionalNested] AS [o0] ON [o].[RootEntityId] = [o0].[RelatedTypeRootEntityId] -LEFT JOIN [OptionalRelated_RequiredNested] AS [o1] ON [o].[RootEntityId] = [o1].[RelatedTypeRootEntityId] -LEFT JOIN [RequiredRelated] AS [r1] ON [r].[Id] = [r1].[RootEntityId] -LEFT JOIN [RequiredRelated_OptionalNested] AS [r2] ON [r1].[RootEntityId] = [r2].[RelatedTypeRootEntityId] -LEFT JOIN [RequiredRelated_RequiredNested] AS [r3] ON [r1].[RootEntityId] = [r3].[RelatedTypeRootEntityId] -LEFT JOIN [OptionalRelated_NestedCollection] AS [o2] ON [o].[RootEntityId] = [o2].[RelatedTypeRootEntityId] -LEFT JOIN ( - SELECT [r4].[RootEntityId], [r4].[Id], [r4].[Int], [r4].[Name], [r4].[String], [r5].[RelatedTypeRootEntityId], [r5].[RelatedTypeId], [r6].[RelatedTypeRootEntityId] AS [RelatedTypeRootEntityId0], [r6].[RelatedTypeId] AS [RelatedTypeId0], [r7].[RelatedTypeRootEntityId] AS [RelatedTypeRootEntityId1], [r7].[RelatedTypeId] AS [RelatedTypeId1], [r7].[Id] AS [Id0], [r7].[Int] AS [Int0], [r7].[Name] AS [Name0], [r7].[String] AS [String0], [r5].[Id] AS [Id1], [r5].[Int] AS [Int1], [r5].[Name] AS [Name1], [r5].[String] AS [String1], [r6].[Id] AS [Id2], [r6].[Int] AS [Int2], [r6].[Name] AS [Name2], [r6].[String] AS [String2] - FROM [RelatedCollection] AS [r4] - LEFT JOIN [RelatedCollection_OptionalNested] AS [r5] ON [r4].[RootEntityId] = [r5].[RelatedTypeRootEntityId] AND [r4].[Id] = [r5].[RelatedTypeId] - LEFT JOIN [RelatedCollection_RequiredNested] AS [r6] ON [r4].[RootEntityId] = [r6].[RelatedTypeRootEntityId] AND [r4].[Id] = [r6].[RelatedTypeId] - LEFT JOIN [RelatedCollection_NestedCollection] AS [r7] ON [r4].[RootEntityId] = [r7].[RelatedTypeRootEntityId] AND [r4].[Id] = [r7].[RelatedTypeId] -) AS [s] ON [r].[Id] = [s].[RootEntityId] -LEFT JOIN [RequiredRelated_NestedCollection] AS [r8] ON [r1].[RootEntityId] = [r8].[RelatedTypeRootEntityId] -WHERE ( - SELECT [r0].[Int] - FROM [RelatedCollection] AS [r0] - WHERE [r].[Id] = [r0].[RootEntityId] - ORDER BY (SELECT 1) - OFFSET @i ROWS FETCH NEXT 1 ROWS ONLY) = 8 -ORDER BY [r].[Id], [o].[RootEntityId], [o0].[RelatedTypeRootEntityId], [o1].[RelatedTypeRootEntityId], [r1].[RootEntityId], [r2].[RelatedTypeRootEntityId], [r3].[RelatedTypeRootEntityId], [o2].[RelatedTypeRootEntityId], [o2].[Id], [s].[RootEntityId], [s].[Id], [s].[RelatedTypeRootEntityId], [s].[RelatedTypeId], [s].[RelatedTypeRootEntityId0], [s].[RelatedTypeId0], [s].[RelatedTypeRootEntityId1], [s].[RelatedTypeId1], [s].[Id0], [r8].[RelatedTypeRootEntityId] -"""); + AssertSql(); } public override async Task Index_column() { await base.Index_column(); - AssertSql( - """ -SELECT [r].[Id], [r].[Name], [o].[RootEntityId], [o].[Id], [o].[Int], [o].[Name], [o].[String], [o0].[RelatedTypeRootEntityId], [o1].[RelatedTypeRootEntityId], [r1].[RootEntityId], [r2].[RelatedTypeRootEntityId], [r3].[RelatedTypeRootEntityId], [o2].[RelatedTypeRootEntityId], [o2].[Id], [o2].[Int], [o2].[Name], [o2].[String], [o0].[Id], [o0].[Int], [o0].[Name], [o0].[String], [o1].[Id], [o1].[Int], [o1].[Name], [o1].[String], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Name], [s].[String], [s].[RelatedTypeRootEntityId], [s].[RelatedTypeId], [s].[RelatedTypeRootEntityId0], [s].[RelatedTypeId0], [s].[RelatedTypeRootEntityId1], [s].[RelatedTypeId1], [s].[Id0], [s].[Int0], [s].[Name0], [s].[String0], [s].[Id1], [s].[Int1], [s].[Name1], [s].[String1], [s].[Id2], [s].[Int2], [s].[Name2], [s].[String2], [r1].[Id], [r1].[Int], [r1].[Name], [r1].[String], [r8].[RelatedTypeRootEntityId], [r8].[Id], [r8].[Int], [r8].[Name], [r8].[String], [r2].[Id], [r2].[Int], [r2].[Name], [r2].[String], [r3].[Id], [r3].[Int], [r3].[Name], [r3].[String] -FROM [RootEntity] AS [r] -LEFT JOIN [OptionalRelated] AS [o] ON [r].[Id] = [o].[RootEntityId] -LEFT JOIN [OptionalRelated_OptionalNested] AS [o0] ON [o].[RootEntityId] = [o0].[RelatedTypeRootEntityId] -LEFT JOIN [OptionalRelated_RequiredNested] AS [o1] ON [o].[RootEntityId] = [o1].[RelatedTypeRootEntityId] -LEFT JOIN [RequiredRelated] AS [r1] ON [r].[Id] = [r1].[RootEntityId] -LEFT JOIN [RequiredRelated_OptionalNested] AS [r2] ON [r1].[RootEntityId] = [r2].[RelatedTypeRootEntityId] -LEFT JOIN [RequiredRelated_RequiredNested] AS [r3] ON [r1].[RootEntityId] = [r3].[RelatedTypeRootEntityId] -LEFT JOIN [OptionalRelated_NestedCollection] AS [o2] ON [o].[RootEntityId] = [o2].[RelatedTypeRootEntityId] -LEFT JOIN ( - SELECT [r4].[RootEntityId], [r4].[Id], [r4].[Int], [r4].[Name], [r4].[String], [r5].[RelatedTypeRootEntityId], [r5].[RelatedTypeId], [r6].[RelatedTypeRootEntityId] AS [RelatedTypeRootEntityId0], [r6].[RelatedTypeId] AS [RelatedTypeId0], [r7].[RelatedTypeRootEntityId] AS [RelatedTypeRootEntityId1], [r7].[RelatedTypeId] AS [RelatedTypeId1], [r7].[Id] AS [Id0], [r7].[Int] AS [Int0], [r7].[Name] AS [Name0], [r7].[String] AS [String0], [r5].[Id] AS [Id1], [r5].[Int] AS [Int1], [r5].[Name] AS [Name1], [r5].[String] AS [String1], [r6].[Id] AS [Id2], [r6].[Int] AS [Int2], [r6].[Name] AS [Name2], [r6].[String] AS [String2] - FROM [RelatedCollection] AS [r4] - LEFT JOIN [RelatedCollection_OptionalNested] AS [r5] ON [r4].[RootEntityId] = [r5].[RelatedTypeRootEntityId] AND [r4].[Id] = [r5].[RelatedTypeId] - LEFT JOIN [RelatedCollection_RequiredNested] AS [r6] ON [r4].[RootEntityId] = [r6].[RelatedTypeRootEntityId] AND [r4].[Id] = [r6].[RelatedTypeId] - LEFT JOIN [RelatedCollection_NestedCollection] AS [r7] ON [r4].[RootEntityId] = [r7].[RelatedTypeRootEntityId] AND [r4].[Id] = [r7].[RelatedTypeId] -) AS [s] ON [r].[Id] = [s].[RootEntityId] -LEFT JOIN [RequiredRelated_NestedCollection] AS [r8] ON [r1].[RootEntityId] = [r8].[RelatedTypeRootEntityId] -WHERE ( - SELECT [r0].[Int] - FROM [RelatedCollection] AS [r0] - WHERE [r].[Id] = [r0].[RootEntityId] - ORDER BY (SELECT 1) - OFFSET [r].[Id] - 1 ROWS FETCH NEXT 1 ROWS ONLY) = 8 -ORDER BY [r].[Id], [o].[RootEntityId], [o0].[RelatedTypeRootEntityId], [o1].[RelatedTypeRootEntityId], [r1].[RootEntityId], [r2].[RelatedTypeRootEntityId], [r3].[RelatedTypeRootEntityId], [o2].[RelatedTypeRootEntityId], [o2].[Id], [s].[RootEntityId], [s].[Id], [s].[RelatedTypeRootEntityId], [s].[RelatedTypeId], [s].[RelatedTypeRootEntityId0], [s].[RelatedTypeId0], [s].[RelatedTypeRootEntityId1], [s].[RelatedTypeId1], [s].[Id0], [r8].[RelatedTypeRootEntityId] -"""); + AssertSql(); } public override async Task Index_out_of_bounds() { await base.Index_out_of_bounds(); - AssertSql( - """ -SELECT [r].[Id], [r].[Name], [o].[RootEntityId], [o].[Id], [o].[Int], [o].[Name], [o].[String], [o0].[RelatedTypeRootEntityId], [o1].[RelatedTypeRootEntityId], [r1].[RootEntityId], [r2].[RelatedTypeRootEntityId], [r3].[RelatedTypeRootEntityId], [o2].[RelatedTypeRootEntityId], [o2].[Id], [o2].[Int], [o2].[Name], [o2].[String], [o0].[Id], [o0].[Int], [o0].[Name], [o0].[String], [o1].[Id], [o1].[Int], [o1].[Name], [o1].[String], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Name], [s].[String], [s].[RelatedTypeRootEntityId], [s].[RelatedTypeId], [s].[RelatedTypeRootEntityId0], [s].[RelatedTypeId0], [s].[RelatedTypeRootEntityId1], [s].[RelatedTypeId1], [s].[Id0], [s].[Int0], [s].[Name0], [s].[String0], [s].[Id1], [s].[Int1], [s].[Name1], [s].[String1], [s].[Id2], [s].[Int2], [s].[Name2], [s].[String2], [r1].[Id], [r1].[Int], [r1].[Name], [r1].[String], [r8].[RelatedTypeRootEntityId], [r8].[Id], [r8].[Int], [r8].[Name], [r8].[String], [r2].[Id], [r2].[Int], [r2].[Name], [r2].[String], [r3].[Id], [r3].[Int], [r3].[Name], [r3].[String] -FROM [RootEntity] AS [r] -LEFT JOIN [OptionalRelated] AS [o] ON [r].[Id] = [o].[RootEntityId] -LEFT JOIN [OptionalRelated_OptionalNested] AS [o0] ON [o].[RootEntityId] = [o0].[RelatedTypeRootEntityId] -LEFT JOIN [OptionalRelated_RequiredNested] AS [o1] ON [o].[RootEntityId] = [o1].[RelatedTypeRootEntityId] -LEFT JOIN [RequiredRelated] AS [r1] ON [r].[Id] = [r1].[RootEntityId] -LEFT JOIN [RequiredRelated_OptionalNested] AS [r2] ON [r1].[RootEntityId] = [r2].[RelatedTypeRootEntityId] -LEFT JOIN [RequiredRelated_RequiredNested] AS [r3] ON [r1].[RootEntityId] = [r3].[RelatedTypeRootEntityId] -LEFT JOIN [OptionalRelated_NestedCollection] AS [o2] ON [o].[RootEntityId] = [o2].[RelatedTypeRootEntityId] -LEFT JOIN ( - SELECT [r4].[RootEntityId], [r4].[Id], [r4].[Int], [r4].[Name], [r4].[String], [r5].[RelatedTypeRootEntityId], [r5].[RelatedTypeId], [r6].[RelatedTypeRootEntityId] AS [RelatedTypeRootEntityId0], [r6].[RelatedTypeId] AS [RelatedTypeId0], [r7].[RelatedTypeRootEntityId] AS [RelatedTypeRootEntityId1], [r7].[RelatedTypeId] AS [RelatedTypeId1], [r7].[Id] AS [Id0], [r7].[Int] AS [Int0], [r7].[Name] AS [Name0], [r7].[String] AS [String0], [r5].[Id] AS [Id1], [r5].[Int] AS [Int1], [r5].[Name] AS [Name1], [r5].[String] AS [String1], [r6].[Id] AS [Id2], [r6].[Int] AS [Int2], [r6].[Name] AS [Name2], [r6].[String] AS [String2] - FROM [RelatedCollection] AS [r4] - LEFT JOIN [RelatedCollection_OptionalNested] AS [r5] ON [r4].[RootEntityId] = [r5].[RelatedTypeRootEntityId] AND [r4].[Id] = [r5].[RelatedTypeId] - LEFT JOIN [RelatedCollection_RequiredNested] AS [r6] ON [r4].[RootEntityId] = [r6].[RelatedTypeRootEntityId] AND [r4].[Id] = [r6].[RelatedTypeId] - LEFT JOIN [RelatedCollection_NestedCollection] AS [r7] ON [r4].[RootEntityId] = [r7].[RelatedTypeRootEntityId] AND [r4].[Id] = [r7].[RelatedTypeId] -) AS [s] ON [r].[Id] = [s].[RootEntityId] -LEFT JOIN [RequiredRelated_NestedCollection] AS [r8] ON [r1].[RootEntityId] = [r8].[RelatedTypeRootEntityId] -WHERE ( - SELECT [r0].[Int] - FROM [RelatedCollection] AS [r0] - WHERE [r].[Id] = [r0].[RootEntityId] - ORDER BY (SELECT 1) - OFFSET 9999 ROWS FETCH NEXT 1 ROWS ONLY) = 8 -ORDER BY [r].[Id], [o].[RootEntityId], [o0].[RelatedTypeRootEntityId], [o1].[RelatedTypeRootEntityId], [r1].[RootEntityId], [r2].[RelatedTypeRootEntityId], [r3].[RelatedTypeRootEntityId], [o2].[RelatedTypeRootEntityId], [o2].[Id], [s].[RootEntityId], [s].[Id], [s].[RelatedTypeRootEntityId], [s].[RelatedTypeId], [s].[RelatedTypeRootEntityId0], [s].[RelatedTypeId0], [s].[RelatedTypeRootEntityId1], [s].[RelatedTypeId1], [s].[Id0], [r8].[RelatedTypeRootEntityId] -"""); + AssertSql(); } #endregion Index diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/Relationships/OwnedNavigations/OwnedNavigationsCollectionSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/Relationships/OwnedNavigations/OwnedNavigationsCollectionSqliteTest.cs index b700e8ad519..cc9770abfb9 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/Relationships/OwnedNavigations/OwnedNavigationsCollectionSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/Relationships/OwnedNavigations/OwnedNavigationsCollectionSqliteTest.cs @@ -14,10 +14,6 @@ public override Task Distinct_projected(QueryTrackingBehavior queryTrackingBehav ? Task.CompletedTask // Base test expects "can't track owned entities" exception, but with SQLite we get "no CROSS APPLY" : AssertApplyNotSupported(() => base.Distinct_projected(queryTrackingBehavior)); - // TODO: #36296 - public override Task Index_column() - => Assert.ThrowsAsync(() => base.Index_column()); - private static async Task AssertApplyNotSupported(Func query) => Assert.Equal( SqliteStrings.ApplyNotSupported,