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 a model Promise breaks types for PrismaPromise #17542

Closed
Tenrys opened this issue Jan 25, 2023 · 2 comments · Fixed by #20215
Closed

Naming a model Promise breaks types for PrismaPromise #17542

Tenrys opened this issue Jan 25, 2023 · 2 comments · Fixed by #20215
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: client types Types in Prisma Client topic: prisma-client topic: type-clash
Milestone

Comments

@Tenrys
Copy link

Tenrys commented Jan 25, 2023

Bug description

This started happening since Prisma 4.9.0, seemingly since #17265.

How to reproduce

Clone the linked reproduction repository, generate the Prisma schema, and open index.ts in VSCode. await will not work on the findMany query and trying to call map on the expected awaited array of customers will give an error.

Expected behavior

No response

Prisma information

Reproduction repository

Environment & setup

  • OS: Manjaro Linux
  • Database: PostgreSQL
  • Node.js version: v16.17.0

Prisma Version

4.9.0
@Tenrys Tenrys added the kind/bug A reported bug. label Jan 25, 2023
@Tenrys
Copy link
Author

Tenrys commented Jan 26, 2023

Same story if you have something in your schema called PromiseType, in this case an enum. In general it seems like if you're not careful, you could generate types overriding the ones required for the Prisma client types to work properly.

@tomhoule tomhoule added bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. topic: client types Types in Prisma Client tech/typescript Issue for tech TypeScript. team/client Issue for team Client. labels Jan 30, 2023
@Jolg42 Jolg42 added topic: type-clash bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. topic: prisma-client and removed bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. labels Jul 13, 2023
SevInf added a commit that referenced this issue Jul 13, 2023
After looking through the issues, we had a couple of more clashes that
needed additional work:

1. `Check` and `Has` collide with built-in `CheckSelect`/`HasSelect`
   types. Those types are not public and not used since prisma 4.16.0,
   so I just removed them from generated file.
2. `Promise` is more complicated and required aliasing built-in type.

Fix #17542
Fix #9669
Close #12469
@Jolg42 Jolg42 added bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Jul 18, 2023
SevInf added a commit that referenced this issue Jul 18, 2023
…#20215)

* fix(client): Allow to use `Check`, `Has` and `Promise` as model names

After looking through the issues, we had a couple of more clashes that
needed additional work:

1. `Check` and `Has` collide with built-in `CheckSelect`/`HasSelect`
   types. Those types are not public and not used since prisma 4.16.0,
   so I just removed them from generated file.
2. `Promise` is more complicated and required aliasing built-in type.

Fix #17542
Fix #9669
Close #12469

* Ensure type alias is still displayed as `Promise` in editor

* Try different method

---------

Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com>
@Jolg42 Jolg42 added this to the 5.1.0 milestone Jul 18, 2023
@SevInf
Copy link
Contributor

SevInf commented Jul 18, 2023

This is fixed and the fix will be published as a part of 5.1 release. You can also check out 5.1.0-dev.25 dev snapshot - we do not recommend using dev snapshots in production, but it should be enough to verify the fix.

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/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: client types Types in Prisma Client topic: prisma-client topic: type-clash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants