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
Type conflict when naming a table {something} and a second table {something}Result #16940
Labels
bug/2-confirmed
Bug has been reproduced and confirmed.
kind/bug
A reported bug.
team/client
Issue for team Client.
tech/engines
Issue for tech Engines.
topic: client types
Types in Prisma Client
topic: type-clash
Milestone
Comments
jkomyno
added
bug/0-unknown
Bug is new, does not have information for reproduction or reproduction could not be confirmed.
tech/engines
Issue for tech Engines.
team/schema
Issue for team Schema.
bug/1-unconfirmed
Bug should have enough information for reproduction, but confirmation has not happened yet.
team/client
Issue for team Client.
and removed
bug/0-unknown
Bug is new, does not have information for reproduction or reproduction could not be confirmed.
team/schema
Issue for team Schema.
labels
Dec 21, 2022
jkomyno
changed the title
conflict when naming a table {something} and a second table {something}Result
Type conflict when naming a table {something} and a second table {something}Result
Dec 21, 2022
SevInf
added a commit
that referenced
this issue
Jul 12, 2023
In some cases, generated types for one of the models will clash with generated types for another. In that case, we would generate duplicate type. This PR fixes this: approach is very different to namespaces proposal I shared earlier. Turns out, most of the conflicts are solved by just renaming default args types from `ModelArgs` to `ModelDefaultArgs`. Deperecated alias for an old name would still be created if it does not conflict. Somewhat different case is `Payload` type. First, they are created at top level of the file, rather then in `Prisma` namespace. @millsp and I agreed that thouse types are not public, so it is safe to move them to namespace and rename them. So, `UserPayload` would now become `Prisma.$UserPayload`. This allows to both use `UserPayload` as a model name as well as use `Batch` as a model name (we have built-in `BatchPayload` type that is unrelated to aforementioned `Payload` types). Fix #19967 Fix #18902 Fix #16940 Fix #9568 Fix #7518
SevInf
added a commit
that referenced
this issue
Jul 12, 2023
In some cases, generated types for one of the models will clash with generated types for another. In that case, we would generate duplicate type. This PR fixes this: approach is very different to namespaces proposal I shared earlier. Turns out, most of the conflicts are solved by just renaming default args types from `ModelArgs` to `ModelDefaultArgs`. Deperecated alias for an old name would still be created if it does not conflict. Somewhat different case is `Payload` type. First, they are created at top level of the file, rather then in `Prisma` namespace. @millsp and I agreed that thouse types are not public, so it is safe to move them to namespace and rename them. So, `UserPayload` would now become `Prisma.$UserPayload`. This allows to both use `UserPayload` as a model name as well as use `Batch` as a model name (we have built-in `BatchPayload` type that is unrelated to aforementioned `Payload` types). Fix #19967 Fix #18902 Fix #16940 Fix #9568 Fix #7518
SevInf
added a commit
that referenced
this issue
Jul 18, 2023
In some cases, generated types for one of the models will clash with generated types for another. In that case, we would generate duplicate type. This PR fixes this: approach is very different to namespaces proposal I shared earlier. Turns out, most of the conflicts are solved by just renaming default args types from `ModelArgs` to `ModelDefaultArgs`. Deperecated alias for an old name would still be created if it does not conflict. Somewhat different case is `Payload` type. First, they are created at top level of the file, rather then in `Prisma` namespace. @millsp and I agreed that thouse types are not public, so it is safe to move them to namespace and rename them. So, `UserPayload` would now become `Prisma.$UserPayload`. This allows to both use `UserPayload` as a model name as well as use `Batch` as a model name (we have built-in `BatchPayload` type that is unrelated to aforementioned `Payload` types). Fix #19967 Fix #18902 Fix #16940 Fix #9568 Fix #7518
SevInf
added a commit
that referenced
this issue
Jul 18, 2023
In some cases, generated types for one of the models will clash with generated types for another. In that case, we would generate duplicate type. This PR fixes this: approach is very different to namespaces proposal I shared earlier. Turns out, most of the conflicts are solved by just renaming default args types from `ModelArgs` to `ModelDefaultArgs`. Deperecated alias for an old name would still be created if it does not conflict. Somewhat different case is `Payload` type. First, they are created at top level of the file, rather then in `Prisma` namespace. @millsp and I agreed that thouse types are not public, so it is safe to move them to namespace and rename them. So, `UserPayload` would now become `Prisma.$UserPayload`. This allows to both use `UserPayload` as a model name as well as use `Batch` as a model name (we have built-in `BatchPayload` type that is unrelated to aforementioned `Payload` types). Fix #19967 Fix #18902 Fix #16940 Fix #9568 Fix #7518
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
This issue is now fixed and the fix will be published as a part of |
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/engines
Issue for tech Engines.
topic: client types
Types in Prisma Client
topic: type-clash
Bug description
There is now a conflict when naming a table {something} and a second table {something}Result
in our case we had Credentials and CredentialsResult both of which referenced each other.
The client generation will create a typescript files that has two conflicting type interfaces named the same thing
How to reproduce
name a table {something} and a second table {something}Result
Expected behavior
That the client generation would namespace the types or that the docs would mark Result as a reserved word not to be used in the table names
Prisma information
// Add your code using Prisma Client
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: