Multiple filter expressions in fetchXml are not taken into account
DigitalFlow opened this issue · 2 comments
Hi @jordimontana82,
hope you're doing well.
I just stumbled upon an issue that lies in a difference between FetchXml and QueryExpressions:
Fetch Xml allows multiple top level filter elements, while QueryExpressions only support one top level filter with nested sub filters.
FetchXml schema:
https://docs.microsoft.com/de-de/powerapps/developer/common-data-service/fetchxml-schema
<xs:element ref="filter" minOccurs="0" />
When now executing the following fetch request in FakeXrmEasy and having two accounts both named "Adventure Works", but with differing cities (one with Berlin, one with Paris for example), FakeXrmEasy will return both of them.
It seems only the first filter node is evaluated:
<fetch no-lock="true">
<entity name="account">
<attribute name="name" />
<filter>
<condition attribute="name" operator="eq" value="Adventure Works" />
</filter>
<filter>
<condition attribute="address1_city" operator="eq" value="Berlin" />
</filter>
</entity>
</fetch>
When rewriting it to a single filter with nested filters, it works as expected:
<fetch no-lock="true">
<entity name="account">
<attribute name="name" />
<filter operator="and">
<filter>
<condition attribute="name" operator="eq" value="Adventure Works" />
</filter>
<filter>
<condition attribute="address1_city" operator="eq" value="Berlin" />
</filter>
</filter>
</entity>
</fetch>
Since the first example is a valid fetchXml as well however, we should probably handle this case as well.
What do you think?
Kind Regards,
Florian
Hi Betim,
thanks for your response.
Yes, I'm sure your PR will fix this, thanks a lot.
Let's hope it gets merged soon :)
Kind Regards,
Florian