Skip to content

Commit

Permalink
adding test for issue #7654
Browse files Browse the repository at this point in the history
  • Loading branch information
maumar committed Apr 13, 2017
1 parent 45f40c7 commit 28a2d66
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/EFCore.Specification.Tests/ComplexNavigationsQueryTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4089,6 +4089,28 @@ public virtual void Navigation_filter_navigation_grouping_ordering_by_group_key(
verifyOrdered: true);
}

[ConditionalFact]
public virtual void Nested_group_join_with_take()
{
AssertQuery<Level1, Level2>(
(l1s, l2s) => from l1_outer in
(from l1_inner in l1s
join l2_inner in l2s on l1_inner.Id equals l2_inner.Level1_Optional_Id into grouping_inner
from l2_inner in grouping_inner.DefaultIfEmpty()
select l2_inner).Take(2)
join l2_outer in l2s on l1_outer.Id equals l2_outer.Level1_Optional_Id into grouping_outer
from l2_outer in grouping_outer.DefaultIfEmpty()
select l2_outer.Name,
(l1s, l2s) => from l1_outer in
(from l1_inner in l1s
join l2_inner in l2s on l1_inner.Id equals l2_inner.Level1_Optional_Id into grouping_inner
from l2_inner in grouping_inner.DefaultIfEmpty()
select l2_inner).Take(2)
join l2_outer in l2s on MaybeScalar<int>(l1_outer, () => l1_outer.Id) equals l2_outer.Level1_Optional_Id into grouping_outer
from l2_outer in grouping_outer.DefaultIfEmpty()
select Maybe(l2_outer, () => l2_outer.Name));
}

private static TResult Maybe<TResult>(object caller, Func<TResult> expression) where TResult : class
{
if (caller == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.EntityFrameworkCore.Specification.Tests;
using Microsoft.EntityFrameworkCore.Specification.Tests.TestUtilities.Xunit;

namespace Microsoft.EntityFrameworkCore.InMemory.FunctionalTests
{
Expand All @@ -11,5 +12,11 @@ public ComplexNavigationsQueryInMemoryTest(ComplexNavigationsQueryInMemoryFixtur
: base(fixture)
{
}

[ConditionalFact(Skip = "issue #4311")]
public override void Nested_group_join_with_take()
{
base.Nested_group_join_with_take();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2659,6 +2659,22 @@ FROM [Level2] AS [l20]
ORDER BY [l2.OneToMany_Required_Self_Inverse0].[Name]");
}

public override void Nested_group_join_with_take()
{
base.Nested_group_join_with_take();

AssertSql(
@"@__p_0: 2
SELECT [l2_outer].[Name]
FROM (
SELECT TOP(@__p_0) [l2_inner].*
FROM [Level1] AS [l1_inner]
LEFT JOIN [Level2] AS [l2_inner] ON [l1_inner].[Id] = [l2_inner].[Level1_Optional_Id]
) AS [t]
LEFT JOIN [Level2] AS [l2_outer] ON [t].[Id] = [l2_outer].[Level1_Optional_Id]");
}

private void AssertSql(params string [] expected)
{
RelationalTestHelpers.AssertBaseline(expected);
Expand Down

0 comments on commit 28a2d66

Please sign in to comment.