Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add regression test for #19584 #24735

Merged
1 commit merged into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -285,5 +285,22 @@ public virtual Task Collection_projection_on_base_type_split(bool async)
AssertCollection(e.BaseCollectionOnBase, a.BaseCollectionOnBase);
});
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Include_on_derived_type_with_queryable_Cast_split(bool async)
{
return AssertQuery(
async,
ss => ss.Set<BaseInheritanceRelationshipEntity>()
.AsSplitQuery()
.Where(b => b.Id >= 4)
.Cast<DerivedInheritanceRelationshipEntity>()
.Include(e => e.DerivedCollectionOnDerived),
elementAsserter: (e, a) =>
{
AssertInclude(e, a, new ExpectedInclude<DerivedInheritanceRelationshipEntity>(i => i.DerivedCollectionOnDerived));
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,22 @@ public virtual Task Collection_projection_on_base_type(bool async)
});
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Include_on_derived_type_with_queryable_Cast(bool async)
{
return AssertQuery(
async,
ss => ss.Set<BaseInheritanceRelationshipEntity>()
.Where(b => b.Id >= 4)
.Cast<DerivedInheritanceRelationshipEntity>()
.Include(e => e.DerivedCollectionOnDerived),
elementAsserter: (e, a) =>
{
AssertInclude(e, a, new ExpectedInclude<DerivedInheritanceRelationshipEntity>(i => i.DerivedCollectionOnDerived));
});
}

protected InheritanceRelationshipsContext CreateContext()
=> Fixture.CreateContext();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,24 @@ FROM [BaseEntities] AS [b]
ORDER BY [b].[Id], [b0].[Id]");
}

public override async Task Include_on_derived_type_with_queryable_Cast(bool async)
{
await base.Include_on_derived_type_with_queryable_Cast(async);

AssertSql(
@"SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [b0].[BaseInheritanceRelationshipEntityId], [b0].[Id], [b0].[Name], [b].[OwnedReferenceOnBase_Id], [b].[OwnedReferenceOnBase_Name], [b1].[DerivedInheritanceRelationshipEntityId], [b1].[Id], [b1].[Name], [b].[OwnedReferenceOnDerived_Id], [b].[OwnedReferenceOnDerived_Name], [t].[Id], [t].[Discriminator], [t].[Name], [t].[ParentId], [t].[DerivedInheritanceRelationshipEntityId]
FROM [BaseEntities] AS [b]
LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b0] ON [b].[Id] = [b0].[BaseInheritanceRelationshipEntityId]
LEFT JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b1] ON [b].[Id] = [b1].[DerivedInheritanceRelationshipEntityId]
LEFT JOIN (
SELECT [b2].[Id], [b2].[Discriminator], [b2].[Name], [b2].[ParentId], [b2].[DerivedInheritanceRelationshipEntityId]
FROM [BaseCollectionsOnDerived] AS [b2]
WHERE [b2].[Discriminator] = N'DerivedCollectionOnDerived'
) AS [t] ON [b].[Id] = [t].[DerivedInheritanceRelationshipEntityId]
WHERE [b].[Id] >= 4
ORDER BY [b].[Id], [b0].[BaseInheritanceRelationshipEntityId], [b0].[Id], [b1].[DerivedInheritanceRelationshipEntityId], [b1].[Id], [t].[Id]");
}

public override async Task Include_collection_with_inheritance_split(bool async)
{
await base.Include_collection_with_inheritance_split(async);
Expand Down Expand Up @@ -1245,6 +1263,39 @@ FROM [BaseEntities] AS [b]
ORDER BY [b].[Id]");
}

public override async Task Include_on_derived_type_with_queryable_Cast_split(bool async)
{
await base.Include_on_derived_type_with_queryable_Cast_split(async);

AssertSql(
@"SELECT [b].[Id], [b].[Discriminator], [b].[Name], [b].[BaseId], [b].[OwnedReferenceOnBase_Id], [b].[OwnedReferenceOnBase_Name], [b].[OwnedReferenceOnDerived_Id], [b].[OwnedReferenceOnDerived_Name]
FROM [BaseEntities] AS [b]
WHERE [b].[Id] >= 4
ORDER BY [b].[Id]",
//
@"SELECT [b0].[BaseInheritanceRelationshipEntityId], [b0].[Id], [b0].[Name], [b].[Id]
FROM [BaseEntities] AS [b]
INNER JOIN [BaseEntities_OwnedCollectionOnBase] AS [b0] ON [b].[Id] = [b0].[BaseInheritanceRelationshipEntityId]
WHERE [b].[Id] >= 4
ORDER BY [b].[Id]",
//
@"SELECT [b0].[DerivedInheritanceRelationshipEntityId], [b0].[Id], [b0].[Name], [b].[Id]
FROM [BaseEntities] AS [b]
INNER JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b0] ON [b].[Id] = [b0].[DerivedInheritanceRelationshipEntityId]
WHERE [b].[Id] >= 4
ORDER BY [b].[Id]",
//
@"SELECT [t].[Id], [t].[Discriminator], [t].[Name], [t].[ParentId], [t].[DerivedInheritanceRelationshipEntityId], [b].[Id]
FROM [BaseEntities] AS [b]
INNER JOIN (
SELECT [b0].[Id], [b0].[Discriminator], [b0].[Name], [b0].[ParentId], [b0].[DerivedInheritanceRelationshipEntityId]
FROM [BaseCollectionsOnDerived] AS [b0]
WHERE [b0].[Discriminator] = N'DerivedCollectionOnDerived'
) AS [t] ON [b].[Id] = [t].[DerivedInheritanceRelationshipEntityId]
WHERE [b].[Id] >= 4
ORDER BY [b].[Id]");
}

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,27 @@ FROM [BaseCollectionsOnBase] AS [b0]
ORDER BY [b].[Id], [t].[Id]");
}

public override async Task Include_on_derived_type_with_queryable_Cast(bool async)
{
await base.Include_on_derived_type_with_queryable_Cast(async);

AssertSql(
@"SELECT [b].[Id], [b].[Name], [d].[BaseId], CASE
WHEN [d].[Id] IS NOT NULL THEN N'DerivedInheritanceRelationshipEntity'
END AS [Discriminator], [b0].[BaseInheritanceRelationshipEntityId], [b0].[Id], [b0].[Name], [b].[OwnedReferenceOnBase_Id], [b].[OwnedReferenceOnBase_Name], [d0].[DerivedInheritanceRelationshipEntityId], [d0].[Id], [d0].[Name], [d].[Id], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t].[Id], [t].[Name], [t].[ParentId], [t].[DerivedInheritanceRelationshipEntityId]
FROM [BaseEntities] AS [b]
LEFT JOIN [DerivedEntities] AS [d] ON [b].[Id] = [d].[Id]
LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b0] ON [b].[Id] = [b0].[BaseInheritanceRelationshipEntityId]
LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d0] ON [b].[Id] = [d0].[DerivedInheritanceRelationshipEntityId]
LEFT JOIN (
SELECT [b1].[Id], [b1].[Name], [b1].[ParentId], [d1].[DerivedInheritanceRelationshipEntityId]
FROM [BaseCollectionsOnDerived] AS [b1]
INNER JOIN [DerivedCollectionsOnDerived] AS [d1] ON [b1].[Id] = [d1].[Id]
) AS [t] ON [b].[Id] = [t].[DerivedInheritanceRelationshipEntityId]
WHERE [b].[Id] >= 4
ORDER BY [b].[Id], [b0].[BaseInheritanceRelationshipEntityId], [b0].[Id], [d0].[DerivedInheritanceRelationshipEntityId], [d0].[Id], [t].[Id]");
}

public override async Task Include_collection_with_inheritance_split(bool async)
{
await base.Include_collection_with_inheritance_split(async);
Expand Down Expand Up @@ -1834,6 +1855,42 @@ FROM [BaseCollectionsOnBase] AS [b0]
ORDER BY [b].[Id]");
}

public override async Task Include_on_derived_type_with_queryable_Cast_split(bool async)
{
await base.Include_on_derived_type_with_queryable_Cast_split(async);

AssertSql(
@"SELECT [b].[Id], [b].[Name], [d].[BaseId], CASE
WHEN [d].[Id] IS NOT NULL THEN N'DerivedInheritanceRelationshipEntity'
END AS [Discriminator], [b].[OwnedReferenceOnBase_Id], [b].[OwnedReferenceOnBase_Name], [d].[Id], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name]
FROM [BaseEntities] AS [b]
LEFT JOIN [DerivedEntities] AS [d] ON [b].[Id] = [d].[Id]
WHERE [b].[Id] >= 4
ORDER BY [b].[Id]",
//
@"SELECT [b0].[BaseInheritanceRelationshipEntityId], [b0].[Id], [b0].[Name], [b].[Id]
FROM [BaseEntities] AS [b]
INNER JOIN [BaseEntities_OwnedCollectionOnBase] AS [b0] ON [b].[Id] = [b0].[BaseInheritanceRelationshipEntityId]
WHERE [b].[Id] >= 4
ORDER BY [b].[Id]",
//
@"SELECT [d0].[DerivedInheritanceRelationshipEntityId], [d0].[Id], [d0].[Name], [b].[Id]
FROM [BaseEntities] AS [b]
INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d0] ON [b].[Id] = [d0].[DerivedInheritanceRelationshipEntityId]
WHERE [b].[Id] >= 4
ORDER BY [b].[Id]",
//
@"SELECT [t].[Id], [t].[Name], [t].[ParentId], [t].[DerivedInheritanceRelationshipEntityId], [b].[Id]
FROM [BaseEntities] AS [b]
INNER JOIN (
SELECT [b0].[Id], [b0].[Name], [b0].[ParentId], [d0].[DerivedInheritanceRelationshipEntityId]
FROM [BaseCollectionsOnDerived] AS [b0]
INNER JOIN [DerivedCollectionsOnDerived] AS [d0] ON [b0].[Id] = [d0].[Id]
) AS [t] ON [b].[Id] = [t].[DerivedInheritanceRelationshipEntityId]
WHERE [b].[Id] >= 4
ORDER BY [b].[Id]");
}

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);

Expand Down