Quirk and Subsequent Findings: Unable to view List in variables tab when used in conjunction with Aggregate List action

2
I have run into a quirk when using the debugger in conjunction with retrieve from database and aggregate list actions.  The more I look into this issue the less I believe this to be a bug, but I could not find documentation/questions addressing this and the functionality was not what I had expected.  I also ran this past some colleagues who have run into very similar issues. Example Use Case: An administrator button that finds all of the entities that meet a certain criteria and shows a popup display with the number of entities.  Here's a simple microflow that achieves this functionality: This works as expected and shows a message displaying the number of TestingEntities that were found in the database.  Where I ran into an issue was I wanted to view the members of the list that were retrieved (say, for example, this list is very small and there is a unique identifier on the "TestingEntity" that you can use to determine which one was retrieved).  To do this in development I would suggest adding a breakpoint to the retrieve action and then utilizing the variables tab to view the specific entities that were retrieved. Now, there are two cases to be addressed here: The Retrieve from Database Action has no x-path constraints The Retrieve from Database Action has x-path constraints   In case (1) the breakpoint adds as expected, but it does not trigger!  The microflow instead runs and shows the message.  Adding a breakpoint to the Count activity gives us the following: The list variable is not visible and we cannot see the members that make up the list that was retrieved. Case (2) becomes a little more problematic.  When we try and add a breakpoint we get this (familiar) error:   This error is generally an indication that you're adding a breakpoint to an activity that is not in the version of the application that is running (i.e. you need to save your project and run locally again) -- this is the error I received that started my initial investigation into this issue.  I had saved the project, redeployed, restarted the debugger, restarted the modeler and was still getting this error which was very confusing and led me to initially believe this was a bug in the platform.  If we add the breakpoint to the count activity then it works exactly as it did in (1) with the list not showing in the variables tab. My hypothesis is that the combination of the Retrieve from Database and subsequent Aggregate List activities triggers an optimization in the Mendix platform to create a more efficient query.  Here are some other things I found: This is not just for the "COUNT" Aggregate List function, it also occurs for SUM/AVERAGE/MINIMUM/MAXIMUM If the list is also being manipulated (i.e. a List Operation is being used or the list is being looped through) then the objects are retrieved as expected in the initial action If the list is passed into a subflow, then the list is retrieved as expected   All in all, it seems to me that this was the intended functionality (we have no real use for the objects, so it's a performance bonus to not actually retrieve them), but the error when adding a breakpoint is very misleading.   My question is: is my hypothesis correct that this is a performance enhancement and the two actions (the retrieve from database and aggregate list function) are actually combined into one action (query) to the database? I'm also curious to hear if anyone else has run into this issue or if others feel this is the expected functionality under these circumstances.  Personally, this was not the expected functionality, but as I looked into this (if my hypothesis is correct) I started to understand why it was the case. Matt  
asked
1 answers
4

Matthew,

You are correct.  When the result of a Database Retrieve activity is used in only 1 List Aggregate activity, those two activities are performed as one and you cannot view the list items via debugging your microflow.  See documentation https://docs.mendix.com/howto6/Optimizing+Microflow+Aggregates  If you use the list that emerges from the database retrieve for any other activities within the microflow, the list will be available in the debug window.

Hope that helps,

Mike

answered