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
Optional Unique ( String? @unique) not working in MongoDB #12827
Comments
Did you run |
Yes ,
db: free shared mongodb atles instance |
Ref: NOTE: |
I do not understand. Your initial message shows how the insert is declined as there is already a value. And that is also how it looks to me after running
What is "not working" for you then? |
Hi @janpio , Prisma 3.12 MongoDB not support partial unique indexs. Here in the code, The first insert have a null value in that field, then other insertions are declined as there is already a value if the field is null or empty. And posgre SQL prisma client support the same |
If you need a partial unique index (as maybe described at https://www.mongodb.com/docs/manual/core/index-partial/#partial-index-with-unique-constraint), that would be a new feature for Prisma that we do not support at all yet and would need a feature request issue. |
Was doing some googling to make sure partial (and maybe wildcard?) indexes were on the roadmap. Glad to have found this issue. @janpio - looks like you have slated this as an enhancement. From your comment above, I just wanted to make sure you didn't still need someone to open a feature request issue. I can do that, if required. |
Any update on this? |
This is driving me mad - is there no way to use partial indexes in prisma? maybe with a rawquery? |
@clearly-outsane , I think you can set manually in the MongoDB/ atlas console. |
Currently facing the same issue while having an optionally present 1-to-1 relationship between models. As stated in mongodb docs mentioned in this comment, to handle such behavior, it would require creating partial index and only indexing documents with relation id field present (?). So, due to not being able to do so, I actually have no idea how can one handle optional 1-to-1's. Is this possible with PostgreSQL? |
Feature request for this kind of index is now tracked at #6974. Closing this issue. |
Bug description
MongoDB Partial Indexes not creating
How to reproduce
schema
index.ts
Expected behavior
MongoDB Partial Indexes
Prisma Doc
It will create two new records where the email is set to NULL in the database.
Prisma information
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: