Improvement on how relationName is generated #26116
Labels
domain/schema
Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc.
kind/improvement
An improvement to existing feature and code.
So I work on a prisma generator. I'm trying to solve some relationship priorities like which one is the main Model and the other one is the relationship. Let's say a User own many Posts. I would think the relationName would be "UserToPost", but with my finding, the
${from}To${to}
is not depending on who own the relation, but on which Model is first in the prisma schema.So this model would generate User.fields.posts.relationName === "UserToPost"
But let's say you order your model alphabetically, the User.fields.posts.relationName === "PostToUser"
It can be ambigus is the relationship is Many-to-many, but I think it would be better if the relationName would slightly be more smart ?
The text was updated successfully, but these errors were encountered: