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

Error parsing attribute "@@index": The Gin index field type Uuid has no default operator class. #14587

Closed
shahinghasemi opened this issue Aug 1, 2022 · 6 comments · Fixed by prisma/prisma-engines#3517
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. topic: extendedIndexes topic: index/gin
Milestone

Comments

@shahinghasemi
Copy link

shahinghasemi commented Aug 1, 2022

Bug description

When I set a GIN index to a field of type array of UUIDs it throws error. However, as far as I can tell, the GIN operator for UUID has been added in postgres v10.

How to reproduce

This is the schema that reproduces the bug:

model Test {
  id                  String              @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
  arrId               String[]            @db.Uuid
  @@index([arrId], map: "idx_Gin", type: Gin)
}

When hover on @@index it says: Error parsing attribute "@@index": The Gin index field type 'Uuid' has no default operator class.

Expected behavior

Should index the field correctly.

Environment & setup

  • OS: Debian
  • Database: PostgreSQL
  • Node.js version:v16.15.0

Prisma Version

prisma                  : 4.1.1
@prisma/client          : 4.1.1
Current platform        : debian-openssl-1.1.x
Query Engine (Node-API) : libquery-engine 8d8414deb360336e4698a65aa45a1fbaf1ce13d8 (at node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Migration Engine        : migration-engine-cli 8d8414deb360336e4698a65aa45a1fbaf1ce13d8 (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine    : introspection-core 8d8414deb360336e4698a65aa45a1fbaf1ce13d8 (at node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary           : prisma-fmt 8d8414deb360336e4698a65aa45a1fbaf1ce13d8 (at node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash    : 8d8414deb360336e4698a65aa45a1fbaf1ce13d8
Studio                  : 0.469.0

@shahinghasemi shahinghasemi added the kind/bug A reported bug. label Aug 1, 2022
@janpio janpio added team/schema Issue for team Schema. bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. topic: index/gin topic: extendedIndexes process/candidate and removed process/candidate labels Aug 2, 2022
@Vija02
Copy link

Vija02 commented Sep 9, 2022

Getting this when running prisma generate.

Error parsing attribute "@@index": The Gin index field type `VarChar` has no default operator class.

@pimeys pimeys self-assigned this Dec 13, 2022
@pimeys
Copy link
Contributor

pimeys commented Dec 13, 2022

It's a validation issue. A workaround until we fix the validation is to explicitly to define the operator class:

datasource db {
  provider = "postgres"
  url      = env("DATABASE_URL")
}

model Test {
  id    String   @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
  arrId String[] @db.Uuid

  @@index([arrId(ops: ArrayOps)], map: "idx_Gin", type: Gin)
}

@pimeys pimeys added bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Dec 13, 2022
@pimeys
Copy link
Contributor

pimeys commented Dec 13, 2022

For the dev fixing this: The validation passes if you remove the native type from the field. We should allow the index without explicit ops definition here even if the native type is defined.

@fullStackDataSolutions
Copy link

I'm having the same issue with

@db.VarChar(255)

How do I set a default for that?

@janpio
Copy link
Member

janpio commented Mar 24, 2023

Please open a new discussion for this @blazestudios23. Thanks.

@adrian-huminiuc
Copy link

@blazestudios23
I found in #17518 a workaround
@@index([reference(ops: raw("gist_trgm_ops"))], type: Gist)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. topic: extendedIndexes topic: index/gin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants