You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When more than one rollup targeting the same parent/child relationship (different target fields) are defined and each contains a different order by clause, the results of the rollup do not correspond to the specified rollup on each target field.
DLRS is using the same context for these currently and because of the default behavior of LREngine, a single SOQL is executed with a "Then By" approach for ordering.
The default behavior of LREngine is to apply order by as follows:
LookupField then by
For each RollupSummaryField in context (in the order specified in the context)
a) if detailOrderBy is specified use detailOrderBy.getName()
b) else use detail.getName()
Since LREngine supports multiple rollupsummary fields with their own OrderBy, there is something to be said for resolving this issue within LREngine instead of DLRS. This comes in to play when no order by is specified as well as one is specified. Order by should be non-deterministic in that case and it will be, but LREngine will apply an order by and it will change depending on the list of RollupSummaryFields passed in the context. It's still non-deterministic but it can vary and an unsuspecting admin can start seeing unexpected results when something "appeared" to be working originally but after adding a new rollup, now its not. The fact that they didn't have an order by to begin with resulted in it being non-determinstic and working as expected but the admin wouldn't understand what's occurring under the covers since default order by behavior is not in the docs.
Example: Two rollups defined on Account from Opportunity, one on StageName and one on Name. The resulting order by generated by LREngine will be AccountId + the order of RollupSummaryFields "detail field" passed in from DLRS. As new rollups on defined on Account, the list of fields passed in will change and hence the outcome will change.
The "simple" solution here is to ensure that DLRS uses the orderby in the ContextKey to ensure each unique order by receives its own SOQL. I think the better solution is to modify LREngine so that it doesn't apply an order by (except for relationshipfield) by default.
While technically a fix, either of these approaches presents a potential regression as current functionality could be impacted to an unsuspecting user/admin/developer since the current approach for all rollups defined on same parent/child relationship is "Then By" in non-deterministic order.
The text was updated successfully, but these errors were encountered:
jondavis9898
added a commit
to jondavis9898/declarative-lookup-rollup-summaries
that referenced
this issue
Aug 13, 2015
…e issue
Tests for ensuring rolled-up value is correct for each rollup and
corresponds to its order by.
testMultiRollupOfDifferentTypesDifferentOrderBy will fail intentionally
to demonstrate the issue
jondavis9898
added a commit
to jondavis9898/declarative-lookup-rollup-summaries
that referenced
this issue
Aug 13, 2015
Even though this addresses the issue, this could appear to cause a
regression to an unsuspecting user/admin/dev since the issue this
addresses could influence existing rollups that were not respecting
proper order by but still could have "appeared" to be working.
When more than one rollup targeting the same parent/child relationship (different target fields) are defined and each contains a different order by clause, the results of the rollup do not correspond to the specified rollup on each target field.
DLRS is using the same context for these currently and because of the default behavior of LREngine, a single SOQL is executed with a "Then By" approach for ordering.
The default behavior of LREngine is to apply order by as follows:
a) if detailOrderBy is specified use detailOrderBy.getName()
b) else use detail.getName()
Since LREngine supports multiple rollupsummary fields with their own OrderBy, there is something to be said for resolving this issue within LREngine instead of DLRS. This comes in to play when no order by is specified as well as one is specified. Order by should be non-deterministic in that case and it will be, but LREngine will apply an order by and it will change depending on the list of RollupSummaryFields passed in the context. It's still non-deterministic but it can vary and an unsuspecting admin can start seeing unexpected results when something "appeared" to be working originally but after adding a new rollup, now its not. The fact that they didn't have an order by to begin with resulted in it being non-determinstic and working as expected but the admin wouldn't understand what's occurring under the covers since default order by behavior is not in the docs.
Example: Two rollups defined on Account from Opportunity, one on StageName and one on Name. The resulting order by generated by LREngine will be AccountId + the order of RollupSummaryFields "detail field" passed in from DLRS. As new rollups on defined on Account, the list of fields passed in will change and hence the outcome will change.
The "simple" solution here is to ensure that DLRS uses the orderby in the ContextKey to ensure each unique order by receives its own SOQL. I think the better solution is to modify LREngine so that it doesn't apply an order by (except for relationshipfield) by default.
While technically a fix, either of these approaches presents a potential regression as current functionality could be impacted to an unsuspecting user/admin/developer since the current approach for all rollups defined on same parent/child relationship is "Then By" in non-deterministic order.
The text was updated successfully, but these errors were encountered: