P
Prisma3mo ago
kangkang

Two table fields are the same

When two table fields are the same, the type typescript generated after relation is lost
3 Replies
Prisma AI Help
Prisma AI Help3mo ago
You chose to compile with the bot. One moment while I piece together your answer… Based on the knowledge sources provided, it appears that you're encountering an issue related to type generation in Prisma when two fields in a model have the same name but different capitalization. This can indeed lead to incorrect type inference and potential conflicts. Let me explain the problem and the current solution: The issue arises when a model contains two fields that point to different models but have the same field name once capitalized. For example, having fields like abc and Abc in the same model can cause problems. This situation can lead to incorrect type generation, as described in the Type name clashes for fields of the same names but capitalized differently issue on GitHub. The problem occurs because Prisma generates types based on the field names, and when they clash after capitalization, it can result in unexpected behavior. To address this issue, Prisma has decided to implement a new schema validation error. This means that if you have a schema with fields that conflict in this way, Prisma will now throw an error during schema validation, forcing users to rename the conflicting fields. It's important to note that this is considered a breaking change, as it will require users to modify their schemas if they encounter this specific case. To resolve this issue in your schema, you should rename one of the conflicting fields to ensure they don't have the same capitalized name. For example, if you have abc and Abc, you might rename one to something like abcField or otherAbc to avoid the conflict. If you need more specific guidance on your particular schema, please provide more details about the exact field names and model structure you're working with. GitHub Issue: Type name clashes 🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
kangkang
kangkangOP3mo ago
@Prisma AI Help how to solve
Nurul
Nurul3mo ago
Hey 👋 I didn't understand your question. Can you please elaborate?

Did you find this page helpful?