Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement of LikeFilter with accent #47

Open
ng-galien opened this issue Feb 24, 2019 · 1 comment
Open

Improvement of LikeFilter with accent #47

ng-galien opened this issue Feb 24, 2019 · 1 comment

Comments

@ng-galien
Copy link

ng-galien commented Feb 24, 2019

I've found the LIKE filter can be improved with french langage because it have accent. (like in the demo dataset).

The original implementation unaccent the uppercase result.
The following query on the base_unit table

SELECT (unaccent(UPPER(name))) FROM public.base_unit;

returns

unaccenttext
--
UNITe
PIeCE
BOiTE DE 2 PCES

We can see that UPPER does not affect accented characters. (Unité -> UNITé)
The following query returns a much better result

SELECT (LOWER(unaccent(name))) FROM public.base_unit;

lowertext
--
unite
piece
boite de 2 pces

I don't know if it has side effects on the entire application.
I'm testing that modification in com.axelor.rpc.filter, first tests are concluant on base unit conversion form.

@Override
  public String getQuery() {
    if (DBHelper.isUnaccentEnabled()) {
      return String.format(
          "LOWER((unaccent(%s))) %s LOWER(unaccent(?)))", getOperand(), getOperator());
    }
    ....
  }

NB: PostgreSQL 11.1 on x86_64-apple-darwin13.4.0, compiled by Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn), 64-bit

capture d ecran 2019-02-24 a 14 08 04

@axeloradmin
Copy link

Thanks, we'll consider the change in next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants