Skip to content

Prisma Client Error, when using filter with string uuid #744

Closed as not planned

Description

@hedwiggggg

Describe the bug
I freshley installed prisma and modeled a database structure. Everything was working fine, but I noticed a bug in prisma studio, when I want to open relations by clicking the Open in new tab link.

Error message
Message: Error in Prisma Client request: 

Invalid `prisma.coursesOnUsers.findMany()` invocation:

  Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("42883"), message: "operator does not exist: uuid ~~* unknown", detail: None, hint: Some("No operator matches the given name and argument types. You might need to add explicit type casts."), position: Some(Original(358)), where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("parse_oper.c"), line: Some(731), routine: Some("op_error") }) }) })
  
Query:
prisma.coursesOnUsers.findMany({
  where: {
    AND: [
      {
       user: {
        id: {
          equals: "3370259b-3c9e-448e-b74a-0ef48560cfe9",
          mode: "insensitive",
        },
       },
      },
    ]
  },
  take: 100,
  skip: 0,
  select: {
    user: true,
    userId: true,
    course: true,
    courseId: true,
  }
})

Seems to be related with the way the query is generated: activerecord-hackery/ransack#709 (comment)

A video showing what I mean
video_06.mp4

To Reproduce

prisma.schema
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}

enum Role {
  STUDENT
  ASSISTANT
  TEACHER
}

enum Visibility {
  PUBLIC
  PRIVATE
}

enum Difficulty {
  EASY
  MEDIUM
  HEAVY
}

model User {
  id String @id @default(uuid()) @db.Uuid

  email    String @db.VarChar
  password String @db.VarChar

  role    Role             @default(STUDENT)
  courses CoursesOnUsers[]
}

model CoursesOnUsers {
  user   User   @relation(fields: [userId], references: [id])
  userId String @db.Uuid

  course   Course @relation(fields: [courseId], references: [id])
  courseId String @db.Uuid

  @@id([userId, courseId])
}

model Course {
  id   String @id @default(uuid()) @db.Uuid
  name String @db.VarChar

  visibility Visibility        @default(PRIVATE)
  users      CoursesOnUsers[]
  topics     TopicsOnCourses[]
}

model TopicsOnCourses {
  topic   Topic  @relation(fields: [topicId], references: [id])
  topicId String @db.Uuid

  course   Course @relation(fields: [courseId], references: [id])
  courseId String @db.Uuid

  @@id([topicId, courseId])
}

model Topic {
  id   String @id @default(uuid()) @db.Uuid
  name String @db.VarChar

  visibility Visibility @default(PRIVATE)

  courses TopicsOnCourses[]
  tasks   TasksOnTopics[]
}

model TasksOnTopics {
  task   Task   @relation(fields: [taskId], references: [id])
  taskId String @db.Uuid

  topic   Topic  @relation(fields: [topicId], references: [id])
  topicId String @db.Uuid

  @@id([taskId, topicId])
}

model Task {
  id   String @id @default(uuid()) @db.Uuid
  name String @db.VarChar

  difficulty Difficulty @default(MEDIUM)
  visibility Visibility @default(PRIVATE)

  topics TasksOnTopics[]
}

Steps to reproduce the behavior:

  1. Migrate the prisma.schema
  2. Go to Prisma Studio
  3. Add some data and relations
  4. Click on the related content
  5. Click on Open in new tab
  6. See error

Expected behavior
Successfully open the new tab and display the data.

Screenshots
See the screen recording.

Desktop (please complete the following information):

  • OS: WSL2 on Windows 10
  • Browser: chrome
  • Version: Version 91.0.4472.124 (Offizieller Build) (64-Bit)

Activity

  1. removed
    topic: hosted data browser
    on Jul 15, 2021
  2. added
    bug/1-unconfirmed
    kind/bug
    on Jul 20, 2021
  3. self-assigned this
    on Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug/1-unconfirmedkind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions