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

Add support for Indexes on Expressions #2504

Open
Tracked by #16311
chrisjaimes opened this issue May 18, 2020 · 4 comments
Open
Tracked by #16311

Add support for Indexes on Expressions #2504

chrisjaimes opened this issue May 18, 2020 · 4 comments
Labels
kind/feature A request for a new feature. status/has-stopgap A stopgap for this functionality has been implemented. team/client Issue for team Client. team/psl-wg team/schema Issue for team Schema. topic: database-functionality topic: indexes topic: introspection topic: postgresql topic: schema

Comments

@chrisjaimes
Copy link

chrisjaimes commented May 18, 2020

Let's say I have the following index expression (which works for defining complex unique constraints) https://www.postgresql.org/docs/current/indexes-expressional.html

create table request (
  from_user int,
  to_user int,
  active boolean default true
);

CREATE UNIQUE INDEX request_index_constraint 
ON request(greatest(from_user,to_user), least(from_user,to_user))
WHERE (active);

When generating the schema, there is no definition for this unique constraint.
findOne method won't be able to target these fields in the where obj.
Index constraints are useful for more complex unique constraints on table columns, and it would be useful to let Prisma find this 'uniqueness' in table rows. Currently, a workaround is the raw function.

@chrisjaimes chrisjaimes changed the title Does prisma support Indexes on Expressions? Add support for Indexes on Expressions? May 18, 2020
@chrisjaimes chrisjaimes changed the title Add support for Indexes on Expressions? Add support for Indexes on Expressions May 18, 2020
@pantharshit00 pantharshit00 added the kind/feature A request for a new feature. label May 19, 2020
@github-actions github-actions bot added the Stale label Jul 22, 2020
@pantharshit00 pantharshit00 added team/client Issue for team Client. team/schema Issue for team Schema. labels Apr 22, 2021
@vimutti77
Copy link

I need this feature for unique two-way combination of columns

@drewcorlin1

This comment was marked as outdated.

@rohanrajpal
Copy link

Did anyone find any workaround meanwhile?

@tclass
Copy link

tclass commented Oct 24, 2023

same problem here, want to use index expressions in postgres, anyone found a workaround for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature A request for a new feature. status/has-stopgap A stopgap for this functionality has been implemented. team/client Issue for team Client. team/psl-wg team/schema Issue for team Schema. topic: database-functionality topic: indexes topic: introspection topic: postgresql topic: schema
Projects
None yet
Development

No branches or pull requests

7 participants