Repository navigation
Closed
prisma/prisma-engines
#3178Labels
bug/2-confirmedBug has been reproduced and confirmed.kind/bugA reported bug.tech/enginesIssue for tech Engines.topic: client apitopic: client typesTypes in Prisma Clienttopic: native database types
Milestone
Description
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
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
Reacted by Robert Aron
Metadata
Metadata
Labels
bug/2-confirmedBug has been reproduced and confirmed.kind/bugA reported bug.tech/enginesIssue for tech Engines.topic: client apitopic: client typesTypes in Prisma Clienttopic: native database types

Activity
pantharshit00 commentedon Sep 6, 2021
Thanks for reporting, I can confirm this bug in
2.31.0-dev.49.dpetrick commentedon Sep 21, 2021
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.
pimeys commentedon Sep 2, 2022
Yep, can still reproduce this. The API should not allow the query if the native type is a UUID.
qe+postgres: exclude `contains` filters on uuid fields
qe+postgres: exclude `contains` filters on uuid fields
qe+postgres: exclude `contains` filters on uuid fields
test: add regression for gh-9007
test(client): Regression test for gh-9007 (#15439)