Skip to content

Commit

Permalink
Do not attempt to validate data types of variable filters
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMpn committed Aug 2, 2024
1 parent fca61e1 commit 3efdbed
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
3 changes: 3 additions & 0 deletions MarkMpn.Sql4Cds.Engine/ExecutionPlan/FetchXmlScan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,9 @@ private void VerifyFilterValueTypes(string entityName, object[] items, DataSourc
if (condition.value == null && (condition.Items == null || condition.Items.Length == 0))
continue;

if (condition.IsVariable)
continue;

var conditionEntity = entityName;

if (condition.entityname != null)
Expand Down
39 changes: 39 additions & 0 deletions MarkMpn.Sql4Cds.Engine/NodeContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ public NodeCompilationContext(
DataSources = dataSources;
Options = options;
ParameterTypes = parameterTypes;
GlobalCalculations = new NestedLoopNode
{
LeftSource = new ComputeScalarNode
{
Source = new ConstantScanNode
{
Values =
{
new Dictionary<string, ScalarExpression>()
}
}
},
OuterReferences = new Dictionary<string, string>()
};
Log = log ?? (msg => { });
}

Expand All @@ -47,6 +61,7 @@ public NodeCompilationContext(
DataSources = parentContext.DataSources;
Options = parentContext.Options;
ParameterTypes = parameterTypes;
GlobalCalculations = parentContext.GlobalCalculations;
Log = parentContext.Log;
_parentContext = parentContext;
}
Expand All @@ -71,6 +86,11 @@ public NodeCompilationContext(
/// </summary>
public DataSource PrimaryDataSource => DataSources[Options.PrimaryDataSource];

/// <summary>
/// Returns a <see cref="NestedLoopNode"/> which can be used to calculate global values to be injected into other nodes
/// </summary>
public NestedLoopNode GlobalCalculations { get; }

/// <summary>
/// A callback function to log messages
/// </summary>
Expand All @@ -87,6 +107,25 @@ public string GetExpressionName()

return $"Expr{++_expressionCounter}";
}

internal void ResetGlobalCalculations()
{
GlobalCalculations.OuterReferences.Clear();
((ComputeScalarNode)GlobalCalculations.LeftSource).Columns.Clear();
}

internal IDataExecutionPlanNodeInternal InsertGlobalCalculations(IRootExecutionPlanNodeInternal rootNode, IDataExecutionPlanNodeInternal source)
{
if (GlobalCalculations.OuterReferences.Count == 0)
return source;

var clone = (NestedLoopNode)GlobalCalculations.Clone();
clone.RightSource = source;
source.Parent = clone;
clone.Parent = rootNode;

return clone;
}
}

/// <summary>
Expand Down

0 comments on commit 3efdbed

Please sign in to comment.