Skip to content

Commit

Permalink
better docs for case-insensitive filtering with SQLite. Resolves DA-460
Browse files Browse the repository at this point in the history
…. Resolves #1858.
  • Loading branch information
jharrell committed Jul 3, 2024
1 parent a163fa4 commit 22405c1
Showing 1 changed file with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,35 @@ The MongoDB uses a RegEx rule for case-insensitive filtering.

### SQLite provider

By default, SQLite itself only [supports case-insensitive comparisons of ASCII characters](https://www.sqlite.org/faq.html#q18). Therefore, Prisma Client does not offer support for case-insensitive filtering with SQLite.
By default, text fields created by Prisma Client in SQLite databases do not support case-insensitive filtering. In SQLite, only [case-insensitive comparisons of ASCII characters](https://www.sqlite.org/faq.html#q18) are possible.

To enable limited support (ASCII only) for case-insensitive filtering on a per-column basis, use `COLLATE NOCASE` when you define table columns:
To enable limited support (ASCII only) for case-insensitive filtering on a per-column basis, you will need to add `COLLATE NOCASE` when you define a text column. For example, if you had the following Prisma Schema model:

```prisma
model User {
id Int @id
email String
}
```

and used `prisma migrate dev --create-only` to create the following migration file:

```sql
-- CreateTable
CREATE TABLE "TestUser" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"email" TEXT NOT NULL
);
```

You would need to add `COLLATE NOCASE` to the `email` column in order to make case-insensitive filtering possible:

```sql
CREATE TABLE mytable (
sample TEXT COLLATE NOCASE /* collating sequence NOCASE */
-- CreateTable
CREATE TABLE "TestUser" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
//highlight-next-line
"email" TEXT NOT NULL COLLATE NOCASE
);
```

Expand Down

0 comments on commit 22405c1

Please sign in to comment.