Difference xpath results

5
Heey Community, While testing my work i got the wrong result back from my retrive. After recreating my xpath in sql in postgres i found that the sql mendix makes was different. After changing how i wrote my xpath i got back the result i wanted. Now my question is why did i get back different results from my 2 xpaths when as far as i know they should give back the same.  Xpath 1: [Projecten.Project_Vestiging = $Vestiging] [Projecten.ProjectRolToewijzing_Project/Projecten.ProjectRolToewijzing/Projecten.ProjectRolToewijzing_Medewerker = $Medewerker] [Projecten.ProjectRolToewijzing_Project/Projecten.ProjectRolToewijzing /Projecten.ProjectRolToewijzing_ProjectRol/Projecten.ProjectRol/_enumTijdslijn = $Search/ProjectRol] [IsAfgerond = false()] [_isActive = true()] [Geannuleerd = empty] [Gepauzeerd = false()] [_Orderballon = false()] Xpath 2: [Projecten.Project_Vestiging = $Vestiging] [Projecten.ProjectRolToewijzing_Project/Projecten.ProjectRolToewijzing [Projecten.ProjectRolToewijzing_Medewerker = $Medewerker] [Projecten.ProjectRolToewijzing_ProjectRol/Projecten.ProjectRol/_enumTijdslijn = $Search/ProjectRol] ] [IsAfgerond = false()] [_isActive = true()] [Geannuleerd = empty] [Gepauzeerd = false()] [_Orderballon = false()] Kind regards, Edo
asked
3 answers
4

Hi Edo,

I think that the first xpath will create a dubble inner join in the actual SQL. The second xpath will only create one inner join due to the notation of the xpath. So the first xpath will probably return more results, due to the double inner join!

You can set the loglevels on TRACE on ConnectionBus_Retrieve to see the OQL/SQL statements that are used. With some manual work on the parameters, you can execute the created queries in PgAdmin to see what it fetches.

Sven.

answered
2

Because they are not the same!

Let's give a basic example, based on the Training Course Management application. You have Courses, Locations, TrainingEvents, Registrations and Trainees.

Give me all Locations a Trainee has to go to for Courses that cost more than 1000 euro's.

[Location_TrainingEvent/TrainingEvent/TrainingEvent_Registration/Registration/Registration_Trainee = '[%CurrentUser%]']
[Location_TrainingEvent/TrainingEvent/TrainingEvent_Course/Course/Price > 1000]
[Location_TrainingEvent/TrainingEvent[TrainingEvent_Course/Course/Price > 1000]/TrainingEvent_Registration/Registration/Registration_Trainee = '[%CurrentUser%]']

Only one of them will give you the correct answer, and it’s the second one. Translated into natural language, the first one reads: Give me all locations a Trainee has to go to that (also) host a course with a cost of more than 1000. This situation, whether you use a sub clause or not, is the same as your question.

answered
1

I’ve wrote 2 blog posts about this behavior with examples and the SQL explained if you are interested in more information on this:

https://blog.stephanbruijnis.dev/posts/semantics-of-xpath-expressions/

https://blog.stephanbruijnis.dev/posts/semantics-of-xpath-expressions-part-2-analysing-the-sql/

 

answered