Skip to content

Commit

Permalink
Fixed filtering on virtual attributes where there are multiple virtua…
Browse files Browse the repository at this point in the history
…l attributes for the same underlying lookup

Fixes #443
  • Loading branch information
MarkMpn committed Mar 27, 2024
1 parent 24f6125 commit a5f0f0a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion MarkMpn.Sql4Cds.Engine/ExecutionPlan/BaseDataNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1081,9 +1081,14 @@ private bool TranslateFetchXMLCriteriaWithVirtualAttributes(NodeCompilationConte
// it's not always the same under the hood.
if (attributeSuffix == "name")
{
// Should normally only be one string virtual attribute related to the lookup attribute and one yomi one. Sometimes
// the yomi version is not flagged as such, and some special cases have additional ones as well
// https://github.com/MarkMpn/Sql4Cds/issues/443
attribute = meta.Attributes
.OfType<StringAttributeMetadata>()
.SingleOrDefault(a => a.AttributeOf == attrName && a.AttributeType == AttributeTypeCode.String && a.YomiOf == null);
.Where(a => a.AttributeOf == attrName && a.AttributeType == AttributeTypeCode.String && a.YomiOf == null)
.OrderBy(a => a.LogicalName == attrName + "name" ? 0 : 1)
.FirstOrDefault();
}
else
{
Expand Down

0 comments on commit a5f0f0a

Please sign in to comment.