From 212cfc4a0f8632e402e38f9577ac901922ae974e Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 15 Oct 2014 13:22:30 -0500 Subject: [PATCH] IDEMPIERE-2207 Use of virtual column in search is broken --- .../src/org/compiere/model/MQuery.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/org.adempiere.base/src/org/compiere/model/MQuery.java b/org.adempiere.base/src/org/compiere/model/MQuery.java index acca3d496f..7c5702d072 100644 --- a/org.adempiere.base/src/org/compiere/model/MQuery.java +++ b/org.adempiere.base/src/org/compiere/model/MQuery.java @@ -1108,9 +1108,20 @@ class Restriction implements Serializable { if (DirectWhereClause != null) return DirectWhereClause; + // verify if is a virtual column, do not prefix tableName if this is a virtualColumn + boolean virtualColumn = false; + if (tableName != null && tableName.length() > 0) { + MTable table = MTable.get(Env.getCtx(), tableName); + for (MColumn col : table.getColumns(false)) { + if (ColumnName.equals(col.getColumnSQL())) { + virtualColumn = true; + break; + } + } + } // StringBuilder sb = new StringBuilder(); - if (tableName != null && tableName.length() > 0) + if (!virtualColumn && tableName != null && tableName.length() > 0) { // Assumes - REPLACE(INITCAP(variable),'s','X') or UPPER(variable) int pos = ColumnName.lastIndexOf('(')+1; // including (