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

Add a configuration option to disallow automatic field additions #91

Open
sdnts opened this issue Apr 2, 2020 · 3 comments
Open

Add a configuration option to disallow automatic field additions #91

sdnts opened this issue Apr 2, 2020 · 3 comments
Labels
domain/schema Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc. kind/feature A request for a new feature. topic: formatting topic: prisma-fmt

Comments

@sdnts
Copy link
Contributor

sdnts commented Apr 2, 2020

When I save this schema:

model User {
  id Int @id
}

model Post {
  id Int @id
  authorId Int
  author User @relation(fields: [authorId], references: [id])
}

it gets corrected to:

model User {
  id    Int    @id
  posts Post[]
}

model Post {
  id       Int  @id
  authorId Int
  author   User @relation(fields: [authorId], references: [id])
}

(notice the extra field in the User model)

which is nice, but today while I was updating the schema that I use in Studio's tests (which has a lot of different kinds of relations), it quickly became very annoying to see new fields pop up all over the place. I think this will generally be an issue for all schemas that heavily rely on relations.

I propose we add a configuration option that disallows the extension from makin any changes to the schema exept formatting.

@sdnts
Copy link
Contributor Author

sdnts commented Apr 2, 2020

Maybe even formatting. Perhaps we can allow people to selectively enable what changes the extension will make to your schema.

@janpio janpio added the kind/feature A request for a new feature. label Apr 2, 2020
@janpio janpio added tech/engines Issue for tech Engines. tech/typescript Issue for tech TypeScript. labels Apr 21, 2020
@nikolasburk
Copy link
Member

I think this is also a broader discussion since afaik it was the plan to always require both sides of a relation, meaning your schema would be illegal if it didn't have posts as the second relation field. In that sense, prisma format just helps you with the typing you'd have to do anyways. I might be wrong, but this was my latest info.

@sdnts
Copy link
Contributor Author

sdnts commented May 5, 2020

@nikolasburk That's correct still. What I meant is that we assume anyone who switches this option on knows what they're doing. In my case, I would have added those fields myself eventually, but with different names (instead of the autogenerated names), for example.
The schema can still stay invalid and the extension can still render red squiggly lines to make that clear.

Perhaps we should invert what I said and have these options "on" by default and let people turn it "off" when they want.

@Jolg42 Jolg42 added the domain/schema Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc. label Nov 16, 2021
@janpio janpio added topic: formatting topic: prisma-fmt and removed tech/engines Issue for tech Engines. tech/typescript Issue for tech TypeScript. labels Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain/schema Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc. kind/feature A request for a new feature. topic: formatting topic: prisma-fmt
Projects
None yet
Development

No branches or pull requests

4 participants