Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0036954
TypeCategorySeverityReproducibilityDate SubmittedLast Update
design defect[Retail Modules] Web POSmajorhave not tried2017-09-26 13:482017-10-26 16:38
ReportermarvintmView Statuspublic 
Assigned Togorka_gil 
PrioritynormalResolutionfixedFixed in VersionRR18Q1
StatusclosedFix in branchFixed in SCM revision540216bb6422
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Review Assigned Tomarvintm
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0036954: buildIdentifier function in ob-cache doesn't take into account property names in the criteria

DescriptionThe buildIdentifier function in ob-cache, which is used by the caching mechanism which is used by OB.Dal.findUsingCache and OB.Dal.queryUsingCache, doesn't take into account property names, only their values, when serializing a criteria.

This means that if somebody tries to use the same cache for two different queries which query the same table but have different criterias, it could happen that incorrect results are returned.

Although this was not considered the proper usage of the API in the original implementation, taking property names into account would make the API friendlier to use, and would protect it against developer mistakes.
Steps To ReproduceLogin in the Web POS. Then, execute the following two queries:

OB.Dal.find(OB.Model.Product, {isGeneric: true}, function(data){console.log(data);})

OB.Dal.find(OB.Model.Product, {bestseller: true}, function(data){console.log(data);})


Verify that they return two different sets of products (makes sense, because the criteria is different).

Now try the following two:

OB.Dal.findUsingCache("productCache", OB.Model.Product, {isGeneric: true}, function(data){console.log(data);})
OB.Dal.findUsingCache("productCache", OB.Model.Product, {bestseller: true}, function(data){console.log(data);})

Both queries are using the same cache (which is something arguably does not make sense), but in any case, they return the same result, which is most likely wrong according to what the developer expected.

If we included the whole criteria in the buildIdentifier function, this would not happen, as two different sets of results would have been created in the cache.
Proposed SolutionChange the buildIdentifier function so that it serializes the whole criteria to JSON. This way, we would not be losing the property names, and this problem would not happen.
TagsNo tags attached.
Attached Files

- Relationships Relation Graph ] Dependency Graph ]

-  Notes
(0099882)
hgbot (developer)
2017-10-13 09:23

Repository: tools/automation/pi-mobile
Changeset: 173c5786f32f3be40d9b0f0ed1ab489ba6abc167
Author: Gorka Gil <gorka.gil <at> openbravo.com>
Date: Fri Oct 13 09:07:10 2017 +0200
URL: http://code.openbravo.com/tools/automation/pi-mobile/rev/173c5786f32f3be40d9b0f0ed1ab489ba6abc167 [^]

Related to issue 36954: buildIdentifier function in ob-cache doesn't take into account property names in the criteria

Added test to check that findUsingCache continues caching queries

---
A src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/system/I36954_FindUsingCache.java
---
(0099883)
hgbot (developer)
2017-10-13 09:24

Repository: erp/pmods/org.openbravo.mobile.core
Changeset: 540216bb64224392b0a4004b80526da5b08579dd
Author: Gorka Gil <gorka.gil <at> openbravo.com>
Date: Tue Oct 10 17:27:37 2017 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.mobile.core/rev/540216bb64224392b0a4004b80526da5b08579dd [^]

Fixed issue 36954: buildIdentifier function in ob-cache doesn't take into account property names in the criteria

Put the serialized params as identifier for caching

Details:
 - Mantained the delete of obj.sql, since some times the params are duplicated.
 - Sometimes the params are "[]" and other "", to unify the empty params added an exception for empty case.
 - Unified the case for remote and local

---
M web/org.openbravo.mobile.core/source/data/ob-cache.js
---

- Issue History
Date Modified Username Field Change
2017-09-26 13:48 marvintm New Issue
2017-09-26 13:48 marvintm Assigned To => Retail
2017-09-26 13:48 marvintm Triggers an Emergency Pack => No
2017-09-26 13:50 marvintm Steps to Reproduce Updated View Revisions
2017-10-02 16:22 gorka_gil Assigned To Retail => gorka_gil
2017-10-09 18:15 gorka_gil Status new => scheduled
2017-10-13 09:23 hgbot Checkin
2017-10-13 09:23 hgbot Note Added: 0099882
2017-10-13 09:24 hgbot Checkin
2017-10-13 09:24 hgbot Note Added: 0099883
2017-10-13 09:24 hgbot Status scheduled => resolved
2017-10-13 09:24 hgbot Resolution open => fixed
2017-10-13 09:24 hgbot Fixed in SCM revision => http://code.openbravo.com/erp/pmods/org.openbravo.mobile.core/rev/540216bb64224392b0a4004b80526da5b08579dd [^]
2017-10-26 16:38 marvintm Review Assigned To => marvintm
2017-10-26 16:38 marvintm Status resolved => closed
2017-10-26 16:38 marvintm Fixed in Version => RR18Q1


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker