Skip to content

Commit

Permalink
Fix OPENJSON postprocessing with split query (dotnet#32978)
Browse files Browse the repository at this point in the history
  • Loading branch information
roji authored Feb 1, 2024
1 parent a8b1664 commit 451514e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ public virtual Expression Process(Expression expression)
switch (expression)
{
case ShapedQueryExpression shapedQueryExpression:
return shapedQueryExpression.UpdateQueryExpression(Visit(shapedQueryExpression.QueryExpression));
return shapedQueryExpression
.UpdateQueryExpression(Visit(shapedQueryExpression.QueryExpression))
.UpdateShaperExpression(Visit(shapedQueryExpression.ShaperExpression));

case SelectExpression selectExpression:
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,42 @@ public virtual async Task Same_collection_with_conflicting_type_mappings_not_sup

#endregion Type mapping inference

[ConditionalFact]
public virtual async Task Ordered_collection_with_split_query()
{
var contextFactory = await InitializeAsync<Context32976>(
onModelCreating: mb => mb.Entity<Context32976.Principal>(),
seed: context =>
{
context.Add(new Context32976.Principal { Ints = [2, 3, 4]});
context.SaveChanges();
});

await using var context = contextFactory.CreateContext();

_ = await context.Set<Context32976.Principal>()
.Where(p => p.Ints.Skip(1).Contains(3))
.Include(p => p.Dependents)
.AsSplitQuery()
.SingleAsync();
}

public class Context32976(DbContextOptions options) : DbContext(options)
{
public class Principal
{
public int Id { get; set; }
public List<int> Ints { get; set; }
public List<Dependent> Dependents { get; set; }
}

public class Dependent
{
public int Id { get; set; }
public Principal Principal { get; set; }
}
}

[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());
Expand Down

0 comments on commit 451514e

Please sign in to comment.