Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prisma format adds invalid fragments to schema if composites are present on a model #10845

Closed
dpetrick opened this issue Dec 23, 2021 · 2 comments · Fixed by prisma/prisma-engines#2560
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. topic: composite-types topic: mongodb topic: prisma format CLI: prisma format
Milestone

Comments

@dpetrick
Copy link
Contributor

Saving the following datamodel:

datasource db {
  provider = "mongodb"
  url      = "mongodb://prisma:prisma@127.0.0.1:27017/test?authSource=admin"
}

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

model A {
  id String  @id @default(dbgenerated()) @map("_id") @db.ObjectId
  b  B
  c  C[]
}

type B {
  b_1 String
  b_2 Int
}

type C {
  c_1 Int
}

Results in the formatter rendering the datamodel like this:

datasource db {
  provider = "mongodb"
  url      = "mongodb://prisma:prisma@127.0.0.1:27017/testdb2?authSource=admin"
}

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

model A {
  id String @id @default(dbgenerated()) @map("_id") @db.ObjectId
  b  B
  c  C[]
     // Note these two. The identation is also off, suggesting it doesn't find a suitable field name.
     B? 
     C?
}

type B {
  b_1 String
  b_2 Int
}

type C {
  c_1 Int
}
@janpio janpio transferred this issue from prisma/prisma-engines Dec 23, 2021
@janpio janpio added bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. topic: prisma-format topic: composite-types topic: mongodb labels Dec 23, 2021
@janpio janpio added this to the 3.8.0 milestone Dec 23, 2021
@pimeys pimeys self-assigned this Jan 5, 2022
@pimeys
Copy link
Contributor

pimeys commented Jan 5, 2022

Can confirm. It sucks.

@janpio
Copy link
Member

janpio commented Jan 6, 2022

Can confirm that 3.8.0-dev.47 does not show the behavior from above any more.

@janpio janpio added topic: prisma format CLI: prisma format and removed topic: prisma-format labels Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. topic: composite-types topic: mongodb topic: prisma format CLI: prisma format
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants