IDEMPIERE-1906 Use postgresql SIMILAR TO instead of LIKE

This commit is contained in:
Carlos Ruiz 2018-01-25 17:57:14 +01:00
parent ffcd468f13
commit 45e1f0c654
3 changed files with 10 additions and 2 deletions

View File

@ -181,6 +181,8 @@ public class DBException extends AdempiereException
* @param e exception * @param e exception
*/ */
public static boolean isInvalidIdentifierError(Exception e) { public static boolean isInvalidIdentifierError(Exception e) {
if (DB.isPostgreSQL())
return isSQLState(e, "42P01");
return isErrorCode(e, 904); return isErrorCode(e, 904);
} }

View File

@ -49,6 +49,7 @@ import java.util.logging.Level;
import javax.swing.event.TableModelListener; import javax.swing.event.TableModelListener;
import javax.swing.table.AbstractTableModel; import javax.swing.table.AbstractTableModel;
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.exceptions.DBException; import org.adempiere.exceptions.DBException;
import org.adempiere.util.ServerContext; import org.adempiere.util.ServerContext;
import org.compiere.Adempiere; import org.compiere.Adempiere;
@ -3542,7 +3543,7 @@ public class GridTable extends AbstractTableModel
if (DBException.isInvalidIdentifierError(e0)) if (DBException.isInvalidIdentifierError(e0))
log.warning("Count - " + e0.getLocalizedMessage() + "\nSQL=" + m_SQL_Count); log.warning("Count - " + e0.getLocalizedMessage() + "\nSQL=" + m_SQL_Count);
else else
log.log(Level.SEVERE, "Count SQL=" + m_SQL_Count, e0); throw new AdempiereException(e0);
return 0; return 0;
} }
finally finally

View File

@ -656,6 +656,11 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
GridField mField = m_findFields[i]; GridField mField = m_findFields[i];
boolean isDisplayed = mField.isDisplayed(); boolean isDisplayed = mField.isDisplayed();
if (DisplayType.isText(mField.getVO().displayType)) {
// for string fields allow searching long strings - useful for like and similar to searches
mField.getVO().FieldLength = 32767; // a conservative max literal string - like oracle extended
mField.getVO().DisplayLength = mField.getVO().FieldLength;
}
if (mField.getVO().displayType == DisplayType.YesNo) { if (mField.getVO().displayType == DisplayType.YesNo) {
// Make Yes-No searchable as list // Make Yes-No searchable as list
GridFieldVO vo = mField.getVO(); GridFieldVO vo = mField.getVO();