You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an implicit many-to-many relationship between two models. Records in model X get associated with records in model Y using connect or create. When I create records of each model using Prismock, then query the result using an include to populate related-record properties, each model-X record comes back with an array containing every record from model-Y.
It might be easier to explain with examples, check out my reproduction and follow the README to see this in action.
In this example, use of a "widget" can be subject to approval. There is a table of approval types -- maybe you need a "license" for it, or "security" has to approve access to it. A relationship captures which widgets need which approval, and also which users are allowed to sign off on a particular type of approval. So, initially a user would not be an approver for any type, then we could make them a "security" approver like prisma.user.update({where: {...}, data: {approverFor: {connect: {name: 'security'}}}).
The bug I think I've found is that if I create a approval types "security" and "license", then create a new user with no approverFor argument, the new user record has an "approverFor" array with both these types. I tried to craft prisma.user.update(...) invocations to remove these "phantom" values but couldn't -- I don't know if entries are actually being made in whatever Prismock uses in-memory as an equivalent of an implicit-relationship table, or if the "include" handler that populates the related records has a bug that makes it ignore the contents of the implicit-table and always return all values from the other table.
UPDATE: I just updated my linked repro to include a new relationship between the Widget and User models, both of which have an autoincrement ID. I previous believed that the issue might be that the model in the "middle" here, ApprovalType, has a String primary key (@id) rather than an auto-increment integer, which I think is unusual. Apparently it happens for auto-ID models too.
The text was updated successfully, but these errors were encountered:
I have an implicit many-to-many relationship between two models. Records in model X get associated with records in model Y using
connect
orcreate
. When I create records of each model using Prismock, then query the result using aninclude
to populate related-record properties, each model-X record comes back with an array containing every record from model-Y.It might be easier to explain with examples, check out my reproduction and follow the README to see this in action.
In this example, use of a "widget" can be subject to approval. There is a table of approval types -- maybe you need a "license" for it, or "security" has to approve access to it. A relationship captures which widgets need which approval, and also which users are allowed to sign off on a particular type of approval. So, initially a user would not be an approver for any type, then we could make them a "security" approver like
prisma.user.update({where: {...}, data: {approverFor: {connect: {name: 'security'}}})
.The bug I think I've found is that if I create a approval types "security" and "license", then create a new user with no
approverFor
argument, the new user record has an "approverFor" array with both these types. I tried to craftprisma.user.update(...)
invocations to remove these "phantom" values but couldn't -- I don't know if entries are actually being made in whatever Prismock uses in-memory as an equivalent of an implicit-relationship table, or if the "include" handler that populates the related records has a bug that makes it ignore the contents of the implicit-table and always return all values from the other table.UPDATE: I just updated my linked repro to include a new relationship between the Widget and User models, both of which have an autoincrement ID. I previous believed that the issue might be that the model in the "middle" here, ApprovalType, has a String primary key (
@id
) rather than an auto-increment integer, which I think is unusual. Apparently it happens for auto-ID models too.The text was updated successfully, but these errors were encountered: