-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Cannot use "set" when joining entities in an explicit ManyToMany table #4032
Comments
Hey @uncvrd Sorry for the late response here. I am unable to reproduce this in the latest version of Prisma. Can you please try this again? If you can still reproduce this in the latest version, please share a sql dump of your database. That will help a lot. |
Hi @pantharshit00 in my case, the code runs fine but no data inserted into ManyToMany table. |
Hey @exs2 Can you please provide a reproduction for that bug? |
I'm now encounter the same error as @uncvrd. reproduce repo https://github.com/PeerasakRattanamanee/4032 |
Workaround: upsert & deleteMany const newArtists = [1,2,3,4,5,6,7];
const response = await ctx.db.release.update({
where: {
id: 1
},
data: {
artists: {
upsert: newArtitst.map(artistId => ({
where: { artistId_releaseId: { artistId, releaseId: 1} },
update: {...},
create: { artist: { connect: { id: artistId }}},
})),
deleteMany: {
releaseId: 1,
artistId: { notIn: newArtists },
},
}
}
}) |
Thanks for the reproduction @PeerasakRattanamanee. I can reproduce this now. Looks like our engine checking logic is applying wrong check when changing ids. Internal note: Use this reproduction https://github.com/PeerasakRattanamanee/4032, use the seed function to initialise data. |
This is still relevant in 2.21.2 and reproducible. Mostly related cascade delete work. |
Was this issue ever solved? How does setting values in an explicit join table relate to referential integrity? |
I can reproduce using on
|
Bug description
It appears that when creating an explicit many-to-many join table in Prisma, I cannot use the keyword
set
when joining related entities during anupdate
. I receive the following error:Given the following
schema.prisma
, I have anArtist
aRelease
and anArtistRelease
join table. This was necessary because I needed to associate averified
property on the join table:However, when I try and use the
update
method andset
theartists
(since all of them might change or be replaced), I run the following command and receive the error above:I attempted to use
set
on an implicit join table I have in my project and it worked as expected. My only idea is that I need to make both therelease
andartist
nullable inArtistRelease
and then create aid
primary key for that instead of using a composite primary key but going off the docs, I didn't see an explicit join table defined this way so I wasn't sure. Any insight here would be appreciated!Expected behavior
I expect to be able to use the
set
method when using an explicit many-to-many join table in Prisma.Environment & setup
EDIT: After more digging, does this have to do with cascade deletes not working yet? #2328
The text was updated successfully, but these errors were encountered: