prisma / studio

🎙️ The easiest way to explore and manipulate your data in all of your Prisma projects.
https://www.prisma.io/studio
1.88k stars 48 forks source link

MongoDB: clicking on Nested Relations fails #731

Open matthewmueller opened 3 years ago

matthewmueller commented 3 years ago

https://user-images.githubusercontent.com/170299/125460614-3f994613-0534-4f27-b7c3-4574537f45a9.mp4

  1. Prisma version (prisma -v or npx prisma -v):
npx prisma version
Environment variables loaded from .env
prisma               : 2.27.0
@prisma/client       : 2.27.0
Current platform     : darwin
Query Engine         : query-engine cdba6ec525e0213cce26f8e4bb23cf556d1479bb (at node_modules/@prisma/engines/query-engine-darwin)
Migration Engine     : migration-engine-cli cdba6ec525e0213cce26f8e4bb23cf556d1479bb (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core cdba6ec525e0213cce26f8e4bb23cf556d1479bb (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary        : prisma-fmt cdba6ec525e0213cce26f8e4bb23cf556d1479bb (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : cdba6ec525e0213cce26f8e4bb23cf556d1479bb
Studio               : 0.410.0
Preview Features     : mongoDb
  1. Logs from Developer Tools Console or Command line, if any:
    
    Message: Error in Prisma Client request: 

Invalid prisma.post.findMany() invocation:

Attempted to serialize scalar 'null' with incompatible type 'String' for field userId.

Query: prisma.post.findMany({ where: { AND: [ ] }, take: 100, skip: 0, select: { id: true, slug: true, title: true, body: true, comments: true, user: true, userId: true, } })


3. Does the issue persist even after updating to the latest `prisma` alpha? (`npm i -D @prisma/cli@dev`)

Yes

4. Prisma schema (if relevant):

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

generator client { provider = "prisma-client-js" previewFeatures = ["mongoDb"] }

model Post { id String @id @default(dbgenerated()) @map("_id") @db.ObjectId slug String @unique title String body String comments Comment[] user User @relation(fields: [userId], references: [id]) userId String @db.ObjectId }

// Comments contain a comment string and connect back to the post. // postId must have @db.ObjectId to match up with Post's id type model Comment { id String @id @default(dbgenerated()) @map("_id") @db.ObjectId post Post @relation(fields: [postId], references: [id]) postId String @db.ObjectId comment String }

model User { id String @id @default(dbgenerated()) @map("_id") @db.ObjectId email String @unique name String? posts Post[] }

janpio commented 3 years ago

Can you run the Prisma query manually on your project with a script?

Initially looks like mongoDB queries behave differently than Relational SQL ones which Studio does not expect (and probably also should not have to).