XPath - Add support to compare to a list (SQL IN operator) - Mendix Forum

XPath - Add support to compare to a list (SQL IN operator)

28

This is a followup on my question --> https://forum.mendix.com/link/questions/88582 .

The example I give in that question is:

---------

I want to select all my Employee's who work on a Location which matches a Location in a list. 

I have a MF with a $LocationList variable, and do a retrieve on the Employee entity and make a XPath like:

[Employee/Employee_Location = $LocationList] , this results in a error that LocationList is of the unsupported type List.

I would suspect something like [Employee/Employee_Location IN $LocationList] , but I'm unable to get my head around it.

---------

The answers given confirm that this is not possible. A workaround is to iterate over the List and do a retrieve for each of the Locations and combine the results. This will however result in x (list size) queries being executed instead of one.

XPath does have some support for this on an attribute level --> Wikimedia/projects/project/editions/edition[@language=('English', 'French' )]

It would be great if there would be some support for this, even if it was only on attribute level.

asked
2 answers

 

In the same vein, there is also the problem of apostrophes. The escape character is not supported by XPath in the current version of Mendix.

Created

Associations in Mendix are saved in a separate table containing only the ID's of both objects so:

[Employee/Employee_Location = $LocationList]

should translate to something like this in SQL:

SELECT 
  "DomainModelName$Employee"
FROM 
  public."DomainModelName$Employee_Location", 
  public."DomainModelName$Employee"
WHERE 
  "DomainModelName$Employee".id = "DomainModelName$Employee_Location"."DomainModelName$employeeid" AND
  "DomainModelName$Employee_Location"."DomainModelName$Location" IN (123456789,98745621,145226542);

Where the numbers for IN(xxx,yyy,zzz) are the ID's from the Location objects.

It would be great if Mendix could add this to the Modeler. I'm not sure how high the impact on performance would be, but I guess that's something Mendix can answer.

Created