Case insensitive unique constraint
See original GitHub issueProblem
It’s really important to keep the casing in some of our columns which are unique ( cannot be duplicated ) which constraint can be overridden so easily by just change the casing
Suggested solutions
I’ve found some articles and the most matching one is this Within schema it’d be great having
model Blog {
...
name String @unique(mode:"insensitive")
}
Alternatives
The second solution which is the only available at the moment is to create another column with lowercased letters and it’ll be the unique one
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Create Unqiue case-insensitive constraint on two varchar fields
In Oracle 10g, how do I add a unique case-insensitive constraint on two varchar fields? For example, given the following records already in...
Read more >How To Make Unique Constraint Case Sensitive In SQL ...
This script creates a case insensitive database and a table in that database that has a case sensitive column with a unique constraint...
Read more >Case insensitive UNIQUE constraints in Postgres - Sean Huber
Adding UNIQUE constraints to tables in Postgres is very easy! Imagine we have the following table: CREATE TABLE users ( id uuid PRIMARY...
Read more >How to Create Case-Insensitive Unique Index - Ed Chen Logic
Using unique case-insensitive constraint in a column sometimes is reasonable in business logic to prevent duplicate items.
Read more >MS-SQL: unique constraint case-insensitive
How do I add a case-insensitive constraint without altering the column collation? I've tried. CONSTRAINT [AK_User_Username_UserType] UNIQUE ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is more likely to be solved by
citext
support in schema. That will come eventually via https://github.com/prisma/prisma/issues/3447 although since citext is an extension instead of built in postgres type, it can take more time.After that you could possibiliy do:
@probablycorey Yes, we are adding support Citext as a type. This is scheduled for 2.16.0. I will also update #3447.