Use postgresql SIMILAR TO instead of LIKE

Description

The postgresql SIMILAR TO function is fully compatible with LIKE but additionally it supports some regular expressions.

http://www.postgresql.org/docs/8.4/static/functions-matching.html#FUNCTIONS-SIMILARTO-REGEXP

With this simple patch:

diff -r 2fbfe2612bde org.compiere.db.postgresql.provider/src/org/compiere/dbPort/ConvertMap_PostgreSQL.java --- a/org.compiere.db.postgresql.provider/src/org/compiere/dbPort/ConvertMap_PostgreSQL.java Wed Apr 16 09:17:02 2014 -0500 +++ b/org.compiere.db.postgresql.provider/src/org/compiere/dbPort/ConvertMap_PostgreSQL.java Wed Apr 16 10:06:49 2014 -0500 @@ -47,6 +47,7 @@ s_pg.put("\\bBLOB\\b", "BYTEA"); // BLOB not directly supported s_pg.put("\\bCLOB\\b", "TEXT"); // CLOB not directly supported s_pg.put("\\bLIMIT\\b","\"limit\""); + s_pg.put("\\bLIKE\\b","SIMILAR TO"); // replace the LIKE for the stronger SIMILAR TO s_pg.put("\\bACTION\\b","\"action\""); s_pg.put("\\bold\\b","\"old\""); s_pg.put("\\bnew\\b","\"new\"");

I was able to make it work.

It would be good to add this to iDempiere? Configurable?

WDYT?

Regards,

Carlos Ruiz

Environment

None

Attachments

1
  • 27 Feb 2015, 02:38 AM

Activity

Show:

Carlos Ruiz January 19, 2018 at 10:21 PM

Murilo Habermann Torquato October 23, 2016 at 10:38 PM

Carlos,

I tested this under 3.1 and development and it's working well.

With this I can return both admin and user bpartner only using a simple pattern:

%(adm|use)%

For experienced users it's a great flexibility, and it's much faster than using the advanced search.

Carlos Ruiz February 27, 2015 at 2:38 AM

Attaching a patch to make it configurable in PostgreSQL/pool.properties adding a key iDempiereUseSimilarToInsteadOfLike=true

Fixed

Details

Assignee

Reporter

Labels

Priority

Created April 16, 2014 at 3:10 PM
Updated July 23, 2024 at 10:09 AM
Resolved January 19, 2018 at 10:03 PM