Skip to content

Client shows contains filter on uuid data type despite not being a valid operation #9007

Closed
prisma/prisma-engines
#3178

Description

@eemmiillyy

Bug description

When trying to query a relation via a uuid data type I get this error:

/Users/emilymorgan/Desktop/bug/node_modules/@prisma/client/runtime/index.js:36067
          throw new import_engine_core3.PrismaClientUnknownRequestError(message, this.prisma._clientVersion);
                ^

PrismaClientUnknownRequestError3 [PrismaClientUnknownRequestError]: 
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 type(s). You might need to add explicit type casts."), position: Some(Original(153)), where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("parse_oper.c"), line: Some(728), routine: Some("op_error") }) }) })
    at cb (/Users/emilymorgan/Desktop/bug/node_modules/@prisma/client/runtime/index.js:36067:17)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  clientVersion: '2.30.0'
}

How to reproduce

Related to prisma/studio#744

Expected behavior

For this operator to not be available if it is invalid on a field of type uuid

Screenshot 2021-08-30 at 11 55 12

Prisma information

Given this schema:

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/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[]
}

I ran migrate.

I added some seeded data - two users and a course.

Then I ran npx prisma generate in a TS project and run the following query:

  const data = await prisma.coursesOnUsers.findMany({
    where: {
      userId: {
        contains: "some-valid-uuid",
        mode: "insensitive",
      },
    },
  });

Environment & setup

  • OS: Mac OS
  • Database: PostgreSQL
  • Node.js version: 16.6

Prisma Version

Environment variables loaded from .env
prisma                : 2.30.0
@prisma/client        : 2.30.0
Current platform      : darwin
Query Engine (Binary) : query-engine 60b19f4a1de4fe95741da371b4c44a92f4d1adcb (at node_modules/@prisma/engines/query-engine-darwin)
Migration Engine      : migration-engine-cli 60b19f4a1de4fe95741da371b4c44a92f4d1adcb (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine  : introspection-core 60b19f4a1de4fe95741da371b4c44a92f4d1adcb (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary         : prisma-fmt 60b19f4a1de4fe95741da371b4c44a92f4d1adcb (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash  : 60b19f4a1de4fe95741da371b4c44a92f4d1adcb
Studio                : 0.422.0

Activity

  1. added
    kind/bug
    on Aug 30, 2021
  2. added
    topic: client types
    bug/1-unconfirmed
    on Aug 30, 2021
  3. pantharshit00 commented on Sep 6, 2021

    @pantharshit00
    Contributor

    Thanks for reporting, I can confirm this bug in 2.31.0-dev.49.

  4. added
    bug/2-confirmed
    and removed
    bug/1-unconfirmed
    on Sep 6, 2021
  5. self-assigned this
    on Sep 17, 2021
  6. dpetrick commented on Sep 21, 2021

    @dpetrick
    Contributor

    Thanks for the report, we're not tackling this now because it the API builder doesn't know about native types right now, plus it didn't pop up so far so we're holding off.

  7. self-assigned this
    on Sep 2, 2022
  8. pimeys commented on Sep 2, 2022

    @pimeys

    Yep, can still reproduce this. The API should not allow the query if the native type is a UUID.

  9. removed their assignment
    on Sep 2, 2022
  10. self-assigned this
    on Sep 6, 2022
  11. added this to the 4.4.0 milestone on Sep 9, 2022
  12. self-assigned this
    on Sep 21, 2022
  13. added a commit that references this issue on Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug/2-confirmedkind/bugtech/enginestopic: client apitopic: client typestopic: native database types

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions