prisma: Cannot filter using accent Insensitive
Bug description
I’ve looked in all the places trying to find a way to use
{where: {field: {contains: 'João' } }
and retrieve all the results without matching of accents,
The result I expect:
i.e : João = Joao
I’ve tried to add a collation that ignore accents manually in the field that I’m searching, like this:
// Creating the collation
CREATE COLLATION ignore_accent (provider = icu, locale = 'und-u-ks-level1-kc-true', deterministic = false);
// Creating the table with the collation already applied in the field
CREATE TABLE "protocols" (
"id" SERIAL NOT NULL,
"title" TEXT NOT NULL COLLATE ignore_accent,
CONSTRAINT "protocols_pkey" PRIMARY KEY ("id")
);
But It is showing me this error
ConnectorError(ConnectorError {
user_facing_error: None, kind: QueryError(Error {
kind: Db, cause: Some(DbError { severity: "ERROR",
parsed_severity: Some(Error), code: SqlState(E0A000),
message: "nondeterministic collations are not supported for ILIKE", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("like.c"), line: Some(199), routine: Some("Generic_Text_IC_like")
}) }) })
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 3
- Comments: 17 (1 by maintainers)
Being able to filter by ignoring accent is key also in France 😃 Search is not usable without supporting this extension 😦 Making complex search and filter queries with raw queries is complicated for someone who need an ORM to avoid manipulating SQL raw queries 😃
ps. note that the removeAccents method will return like:
Sostenes Apollo, so I just pick it and make it lower to be like:sostenes apolloIt’s a shame, they don’t deserve to be called developers
need this so bad !
Well that’s a bit harsh and not fair, remember it’s open source software. But I agree with @matmkian (I’m french too) and without this, it’s difficult to consider prisma as properly useable.
I created a migration to handle with this issue
Unfortunately, this only works with query raw!
CREATE EXTENSION unaccent;You should use this command if you’re using postgres.I think if you switch to mysql you’ll be able to run with your custom collation or something like this
@NikitaMasl yeah, I’ve tried everything you can imagine, and it seems to be a prisma limitation
This version @Jolg42
"@prisma/client": "^3.15.2"