Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0034770Openbravo ERPA. Platformpublic2016-12-19 12:102022-02-01 08:09
caristu 
Triage Platform Base 
normalminorN/A
acknowledgedopen 
5
 
 
Core
No
0034770: Add code to auto-detect 'accidental double query' on same OBQuery object
There is a quite common bad coding pattern which calls '.list()' more than one time on the same OBQuery object.

That will call the underlying sql query also 2 times.

Similar some code without good reason calls .count() + then .list() on the same instance. Which leads to a 'select count(*)' + then another 'select *' sql query.

Detecting such pattern is easy with some extra debugging code inside those 2 utility classes.

See attached patch for a rough patch doing some simple tracking.

Not polished yet but did already find 6 issues in fast manual testing + more 'to be triaged' when running erp-try with it applied.

The attached patch logs a WARN + a stacktrace of the location of and 2nd or 3rd call to either list,count,scroll.uniqueResult.

In practice that 2nd location is enough as a pointer and finding the first call in code is very easy in all examples observed so far.
In description
No tags attached.
related to feature request 0033767 closed platform Add code to auto-detect 'accidental double query' on same OBQuery or OBCriteria object 
diff 34770_prototype.diff (4,677) 2016-12-19 12:15
https://issues.openbravo.com/file_download.php?file_id=10192&type=bug
Issue History
2016-12-19 12:10caristuNew Issue
2016-12-19 12:10caristuAssigned To => platform
2016-12-19 12:10caristuModules => Core
2016-12-19 12:10caristuTriggers an Emergency Pack => No
2016-12-19 12:10caristuIssue generated from0033767
2016-12-19 12:10caristuRelationship addedrelated to 0033767
2016-12-19 12:14caristuDescription Updatedbug_revision_view_page.php?rev_id=14054#r14054
2016-12-19 12:14caristuSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=14056#r14056
2016-12-19 12:15caristuFile Added: 34770_prototype.diff
2016-12-19 12:49shuehnerIssue Monitored: shuehner
2016-12-23 08:20caristuStatusnew => acknowledged
2022-02-01 08:09alostaleAssigned Toplatform => Triage Platform Base

There are no notes attached to this issue.