Skip to content

Commit 78a70b2

Browse files
committed
Fix OPENJSON postprocessing with split query (dotnet#32978)
Fixes dotnet#32976
1 parent 71e1891 commit 78a70b2

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

src/EFCore.SqlServer/Query/Internal/SqlServerJsonPostprocessor.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ public virtual Expression Process(Expression expression)
6969
switch (expression)
7070
{
7171
case ShapedQueryExpression shapedQueryExpression:
72-
return shapedQueryExpression.UpdateQueryExpression(Visit(shapedQueryExpression.QueryExpression));
72+
return shapedQueryExpression
73+
.UpdateQueryExpression(Visit(shapedQueryExpression.QueryExpression))
74+
.UpdateShaperExpression(Visit(shapedQueryExpression.ShaperExpression));
7375

7476
case SelectExpression selectExpression:
7577
{

test/EFCore.SqlServer.FunctionalTests/Query/NonSharedPrimitiveCollectionsQuerySqlServerTest.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,42 @@ public virtual async Task Same_collection_with_conflicting_type_mappings_not_sup
871871

872872
#endregion Type mapping inference
873873

874+
[ConditionalFact]
875+
public virtual async Task Ordered_collection_with_split_query()
876+
{
877+
var contextFactory = await InitializeAsync<Context32976>(
878+
onModelCreating: mb => mb.Entity<Context32976.Principal>(),
879+
seed: context =>
880+
{
881+
context.Add(new Context32976.Principal { Ints = [2, 3, 4]});
882+
context.SaveChanges();
883+
});
884+
885+
await using var context = contextFactory.CreateContext();
886+
887+
_ = await context.Set<Context32976.Principal>()
888+
.Where(p => p.Ints.Skip(1).Contains(3))
889+
.Include(p => p.Dependents)
890+
.AsSplitQuery()
891+
.SingleAsync();
892+
}
893+
894+
public class Context32976(DbContextOptions options) : DbContext(options)
895+
{
896+
public class Principal
897+
{
898+
public int Id { get; set; }
899+
public List<int> Ints { get; set; }
900+
public List<Dependent> Dependents { get; set; }
901+
}
902+
903+
public class Dependent
904+
{
905+
public int Id { get; set; }
906+
public Principal Principal { get; set; }
907+
}
908+
}
909+
874910
[ConditionalFact]
875911
public virtual void Check_all_tests_overridden()
876912
=> TestHelpers.AssertAllMethodsOverridden(GetType());

0 commit comments

Comments
 (0)