Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0023011Openbravo ERP00. Application dictionarypublic2013-02-07 16:192013-04-16 19:18
eduardo_Argal 
AugustoMauch 
highmajoralways
closedfixed 
5
 
3.0MP23 
shankarb
Core
No
0023011: Wrong hql query due to hql order by clause of a tab
Depending on the hql order by clause set in a tab, system builds wrong hql query. This is related to the use of common hql functions when defining the order by clause.
Go to:
Sales invoice window Accounting tab.
set the following order by clause:
accountingSchema.name, accountingDate, abs(debit) desc, debit desc, abd(credit) desc, value
Mind that the build hql is wrong. Order by clause in that query is completely different from the one set in the tab.
No tags attached.
blocks defect 0023012 closed eduardo_Argal Accounting tab for transactions does not order properly when negative values exist 
? issue23011.export (2,762) 2013-04-08 14:02
https://issues.openbravo.com/file_download.php?file_id=6079&type=bug
Issue History
2013-02-07 16:19eduardo_ArgalNew Issue
2013-02-07 16:19eduardo_ArgalAssigned To => alostale
2013-02-07 16:19eduardo_ArgalModules => Core
2013-02-07 16:19eduardo_ArgalTriggers an Emergency Pack => No
2013-02-07 16:27eduardo_ArgalRelationship addedblocks 0023012
2013-04-05 13:03AugustoMauchNote Added: 0057742
2013-04-08 11:28AugustoMauchAssigned Toalostale => AugustoMauch
2013-04-08 14:02AugustoMauchFile Added: issue23011.export
2013-04-08 14:02AugustoMauchStatusnew => scheduled
2013-04-08 14:02AugustoMauchfix_in_branch => pi
2013-04-09 13:58AugustoMauchIssue Monitored: shankarb
2013-04-09 13:58AugustoMauchReview Assigned To => shankarb
2013-04-09 13:58AugustoMauchfix_in_branchpi =>
2013-04-09 15:31hgbotCheckin
2013-04-09 15:31hgbotNote Added: 0057804
2013-04-09 15:31hgbotStatusscheduled => resolved
2013-04-09 15:31hgbotResolutionopen => fixed
2013-04-09 15:31hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/c0e933f438dc75587bb1588e7697a547496db0ae [^]
2013-04-09 15:38AugustoMauchNote Added: 0057805
2013-04-09 15:41AugustoMauchNote Added: 0057806
2013-04-15 14:14shankarbNote Added: 0057906
2013-04-15 14:14shankarbStatusresolved => closed
2013-04-15 14:15shankarbFixed in Version => 3.0MP23
2013-04-16 19:18hudsonbotCheckin
2013-04-16 19:18hudsonbotNote Added: 0057941

Notes
(0057742)
AugustoMauch   
2013-04-05 13:03   
HQL order by clase entered by the user:
accountingSchema.name, accountingDate, abs(debit) desc, debit desc, abs(credit) desc, value

Generated HQL order by clase:
order by join_0.name,e.accountingDate,e desc ,e.debit desc ,e desc ,e.value,e.id

'e desc' is added to the HQL query when the abs function is used
(0057804)
hgbot   
2013-04-09 15:31   
Repository: erp/devel/pi
Changeset: c0e933f438dc75587bb1588e7697a547496db0ae
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Mon Apr 08 14:01:36 2013 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/c0e933f438dc75587bb1588e7697a547496db0ae [^]

Fixes issue 23011: Enables using simple functions in HQL order by clause

Now it is possible to use one argument functions (i.e. abs(), max(), min(), etc) as part of the HQL order by clauses. A regular expression is used to check if the orderByParam matches the pattern functionName + '(' + property + ')' + 'desc' (optional). If so, it retrieves the function name and the property name, and resolves the property name. After doing it, it wrappes the resolved property name in its function and adds ' desc' if the function was meant to be sorted in descending order.

---
M modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
---
(0057805)
AugustoMauch   
2013-04-09 15:38   
Test plan:
- Change the HQL clause of the Accounting tab as described in the steps to reproduce
- Open the Sales Invoice window, clear the filter and select a record
- Place a breakpoint at the end of the getOrderByClause method of the AdvancedQueryBuilder class.
- Select the Accounting tab. Eclipse will stop in the breakpoint.
- Check that the value of orderByClause attribute is order by join_0.name,e.accountingDate,abs(e.debit) desc,e.debit desc ,abs(e.credit) desc,e.value,e.id.
(0057806)
AugustoMauch   
2013-04-09 15:41   
Mind that there is a type in the steps to reproduce: the HQL logic should be accountingSchema.name, accountingDate, abs(debit) desc, debit desc, abs(credit) desc, value, not accountingSchema.name, accountingDate, abs(debit) desc, debit desc, abd(credit) desc, value.
(0057906)
shankarb   
2013-04-15 14:14   
Code reviewed and tested in pi changeset b96b3181a12a
(0057941)
hudsonbot   
2013-04-16 19:18   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/8df08bea850d [^]

Maturity status: Test