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

Naming an entity "Query" leads to an error #9307

Closed
Tracked by #7963
dirk-hofmann opened this issue Sep 17, 2021 · 1 comment · Fixed by #20299
Closed
Tracked by #7963

Naming an entity "Query" leads to an error #9307

dirk-hofmann opened this issue Sep 17, 2021 · 1 comment · Fixed by #20299
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. topic: reserved words See https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#naming-conventions
Milestone

Comments

@dirk-hofmann
Copy link

dirk-hofmann commented Sep 17, 2021

Bug description

Naming an entity "Query" in prisma.schema leads to an error when trying to start such a project. The console output will not contain clear information about what's wrong. The auto-generated file \node_modules.prisma\client\index.d.ts contains errors after naming an entity "Query".

How to reproduce

  1. Set up the prisma quickstart project https://www.prisma.io/docs/getting-started/quickstart
  2. In schema.prisma, change the name of the entity "Post" to "Query" wherever it occurs
  3. Run a migration (that regenerates the client as well)
  4. Run "npm run dev" and see the console error output
  5. open \node_modules.prisma\client\index.d.ts and see the TypeScript errors

Expected behavior

The app starts without error and outputs an empty array to the console since it's the prisma quickstart project with an empty database (after our migration).

Prisma information

schema.prisma.txt

Environment & setup

I have run into this error on Windows 10, Node 14.17.6 and Prisma 3.0.2

Prisma Version

Prisma 3.0.2
@dirk-hofmann dirk-hofmann added the kind/bug A reported bug. label Sep 17, 2021
@dirk-hofmann dirk-hofmann changed the title Entity named "Query" leads to invalid auto-generated index.d.ts file Naming an entity "Query" leads to an error Sep 17, 2021
@janpio janpio added topic: reserved words See https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#naming-conventions bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. team/client Issue for team Client. labels Sep 17, 2021
SevInf added a commit that referenced this issue Jul 19, 2023
`DMMFHelper` did not take namespaces into account and merged them all
into single map, based on the name. This is incorrect, since it is
possible to have different type with the same name in different
namespaces. In particular, this broke models named either `Query` or
`Mutation` since they match built in names from `prisma` namespace.

Now we have a separate map for each namespace.

Fix #5749
Fix #9307
Fix #8153
SevInf added a commit that referenced this issue Jul 19, 2023
`DMMFHelper` did not take namespaces into account and merged them all
into single map, based on the name. This is incorrect, since it is
possible to have different type with the same name in different
namespaces. In particular, this broke models named either `Query` or
`Mutation` since they match built in names from `prisma` namespace.

Now we have a separate map for each namespace.

Fix #5749
Fix #9307
Fix #8153
@Jolg42 Jolg42 added this to the 5.1.0 milestone Jul 19, 2023
SevInf added a commit that referenced this issue Jul 20, 2023
`DMMFHelper` did not take namespaces into account and merged them all
into single map, based on the name. This is incorrect, since it is
possible to have different type with the same name in different
namespaces. In particular, this broke models named either `Query` or
`Mutation` since they match built in names from `prisma` namespace.

Now we have a separate map for each namespace.

Fix #5749
Fix #9307
Fix #8153
@SevInf
Copy link
Contributor

SevInf commented Jul 20, 2023

This issue is fixed and will be available in Prisma 5.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. topic: reserved words See https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#naming-conventions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants