prisma: Invalid `….findMany()` invocation: The column `j1.id` does not exist in the current database.
Bug description
After updating to 5.4.0, the following error is shown when running the command provided below with the schema provided below:
prisma:query SELECT "public"."Post"."id" FROM "public"."Post" LEFT JOIN "public"."User" AS "j1" ON ("j1"."email") = ("public"."Post"."email") WHERE ("j1"."email" = $1 AND ("j1"."id" IS NOT NULL)) OFFSET $2
prisma:error
Invalid `prisma.post.findMany()` invocation in
…/prisma21352/src/index.ts:14:33
…
→ 14 console.log(await prisma.post.findMany(
The column `j1.id` does not exist in the current database.
How to reproduce
See also: https://github.com/marvinruder/prisma21352
Run
await prisma.post.findMany({
select: {
id: true,
},
where: {
user: {
email: 'alice@example.com',
}
}
})
with client generated from the provided schema.
Expected behavior
All watchlist
rows related to the specified user (identified by their email) are returned.
Prisma information
// Add your schema.prisma
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
email String @id @db.VarChar(255)
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
user User @relation(fields: [email], references: [email], onUpdate: Cascade, onDelete: Cascade)
email String @db.VarChar(255)
}
// Add your code using Prisma Client
await prisma.post.findMany({
select: {
id: true,
},
where: {
user: {
email: 'alice@example.com',
}
}
})
Environment & setup
- OS: occurring on macOS 14.0 (build 23A344) and in
node:20.8.0-alpine
Docker image - Database: PostgreSQL
- Node.js version: 20.8.0
Prisma Version
prisma : 5.4.0
@prisma/client : 5.4.0
Current platform : darwin-arm64
Query Engine (Node-API) : libquery-engine a5596b96668f0f4b397761ce0956db54e17e48c4 (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Schema Engine : schema-engine-cli a5596b96668f0f4b397761ce0956db54e17e48c4 (at node_modules/@prisma/engines/schema-engine-darwin-arm64)
Schema Wasm : @prisma/prisma-schema-wasm 5.4.0-47.a5596b96668f0f4b397761ce0956db54e17e48c4
Default Engines Hash : a5596b96668f0f4b397761ce0956db54e17e48c4
Studio : 0.494.0
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Reactions: 8
- Comments: 16 (8 by maintainers)
Commits related to this issue
- chore: add reproduction for issue #21352 — committed to prisma/prisma by jkomyno 9 months ago
- chore: add reproduction for issue #21352 (#21354) Co-authored-by: Pierre-Antoine Mills <pierreantoine.urvoy@gmail.com> — committed to prisma/prisma by jkomyno 9 months ago
We are working on a fix now and hope to release it as a patch soon.
Yes, everything works fine after upgrading to 5.4.1 in my project. Thanks for the quick patch!
Works on my end too! Thanks!
Hey everyone 👋 and thanks for your reports. The fix is now available in our latest patch release. https://github.com/prisma/prisma/releases/tag/5.4.1
Thanks, we have a confirmed reproduction internally as well.
Works for me also, thanks!
A minimal reproduction repository is now provided at https://github.com/marvinruder/prisma21352.
part of my schema
I think this is it