The CreateWindowFromTable process generates buggy SQL in the Tab>Order By field when the Value column is a virtual column.

Description

The CreateWindowFromTable process generates buggy SQL in the Tab>Order By field when the Value column is a virtual column.

Steps to reproduce:

  • login to test.idempiere.org as SuperUser

  • open window table and column for table m_movementline

  • start process 'Create Window Tab & Field'

  • in the field Orderby this generates the SQL: 'M_MovementLine.Value'

Opening the new window produces an error because the virtual Value column is only present in the dictionary but not in the db-table.

Fix has already been prepared and tested locally. A pull request has been added.

Environment

None

Activity

Show:

Carlos Ruiz March 26, 2021 at 9:25 AM

, the issue is spread in more points of the code, opened dedicated ticket for that https://idempiere.atlassian.net/browse/IDEMPIERE-4746#icft=IDEMPIERE-4746

Carlos Ruiz March 26, 2021 at 9:13 AM

Hi - yes, agree with your comments

Carlos Ruiz March 26, 2021 at 9:12 AM

Bringing comment from
https://github.com/idempiere/idempiere/pull/638#issuecomment-808023839

Revisiting the issue I found that I had overlooked another error in the code that I thought I had fixed.
Zero is a valid index value. So it should rather be:

...
if (table.getColumnIndex("Value") >= 0 && ...
...

Also for plugin developers this is a trap that is too easy to fall in.
Because of that I would propose to discourage the usage of getcolumnIndex() to check if a column exists and instead
add a dedicated method to the API:
boolean MTable.columnExists(int)
boolean MTable.columnExists(String)
wdyt?

Andreas Sumerauer March 24, 2021 at 10:59 PM

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created March 24, 2021 at 8:47 PM
Updated May 1, 2021 at 10:01 AM
Resolved March 26, 2021 at 9:25 AM