Skip to content

Commit

Permalink
Regression test for #10812
Browse files Browse the repository at this point in the history
  • Loading branch information
smitpatel committed Nov 22, 2019
1 parent 65a102e commit 3d94a7d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7268,6 +7268,20 @@ public virtual Task Cast_OfType_works_correctly(bool async)
ss => ss.Set<Gear>().Cast<Gear>().OfType<Officer>().Select(o => o.FullName));
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Join_inner_source_custom_projection_followed_by_filter(bool async)
{
return AssertQuery(
async,
ss => from ll in ss.Set<LocustLeader>()
join h in ss.Set<Faction>().OfType<LocustHorde>()
.Select(f => new { IsEradicated = f.Name == "Locust" ? (bool?)true : null, f.CommanderName, f.Name })
on ll.Name equals h.CommanderName
where h.IsEradicated != true
select h);
}

protected async Task AssertTranslationFailed(Func<Task> testCode)
{
Assert.Contains(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7241,6 +7241,30 @@ FROM [Gears] AS [g]
WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND ([g].[Discriminator] = N'Officer')");
}

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

AssertSql(
@"SELECT CASE
WHEN [t].[Name] = N'Locust' THEN CAST(1 AS bit)
ELSE NULL
END AS [IsEradicated], [t].[CommanderName], [t].[Name]
FROM [LocustLeaders] AS [l]
INNER JOIN (
SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[CommanderName], [f].[Eradicated]
FROM [Factions] AS [f]
WHERE ([f].[Discriminator] = N'LocustHorde') AND ([f].[Discriminator] = N'LocustHorde')
) AS [t] ON [l].[Name] = [t].[CommanderName]
WHERE [l].[Discriminator] IN (N'LocustLeader', N'LocustCommander') AND ((CASE
WHEN [t].[Name] = N'Locust' THEN CAST(1 AS bit)
ELSE NULL
END <> CAST(1 AS bit)) OR CASE
WHEN [t].[Name] = N'Locust' THEN CAST(1 AS bit)
ELSE NULL
END IS NULL)");
}

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

0 comments on commit 3d94a7d

Please sign in to comment.