Skip to:
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
http://wiki.idempiere.org/en/NF5.1_FindSimilarTo
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.
Attaching a patch to make it configurable in PostgreSQL/pool.properties adding a key iDempiereUseSimilarToInsteadOfLike=true
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