From 9520643c5cbe1e443ae62c356c21fab2cb27f1c7 Mon Sep 17 00:00:00 2001 From: Mark Carrington Date: Mon, 2 Oct 2023 17:41:39 -0700 Subject: [PATCH] Fixed nested loop left outer join with no records returned from inner source --- MarkMpn.Sql4Cds.Engine/ExecutionPlan/NestedLoopNode.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/MarkMpn.Sql4Cds.Engine/ExecutionPlan/NestedLoopNode.cs b/MarkMpn.Sql4Cds.Engine/ExecutionPlan/NestedLoopNode.cs index 08734d5a..c28072d8 100644 --- a/MarkMpn.Sql4Cds.Engine/ExecutionPlan/NestedLoopNode.cs +++ b/MarkMpn.Sql4Cds.Engine/ExecutionPlan/NestedLoopNode.cs @@ -114,7 +114,17 @@ protected override IEnumerable ExecuteInternal(NodeExecutionContext cont } if (!hasRight && JoinType == QualifiedJoinType.LeftOuter) + { + if (rightSchema == null) + { + rightSchema = RightSource.GetSchema(rightCompilationContext); + mergedSchema = GetSchema(context, true); + joinCondition = JoinCondition?.Compile(new ExpressionCompilationContext(context, mergedSchema, null)); + joinConditionContext = joinCondition == null ? null : new ExpressionExecutionContext(context); + } + yield return Merge(left, leftSchema, null, rightSchema); + } } }