Hi prisma team, I wanted to ask about the onDelete...
# orm-help
h
Hi prisma team, I wanted to ask about the onDelete cascasde feature in mysql. whenever I am calling a
prisma.*.delete({...})
And view the data in prisma stdudio , I am getting this error
inconsistent query result field * is required to return data get null instead.
I even added the the onDelete: cascade in the relation.
Note: Deletion behaviors for relations are not yet supported in the Prisma schema so you don't see them anywhere. The behavior will still be enforced by the database though since that's where you configured it.
Is the reason why it is happening ?
šŸ™Œ 1
n
Hey Hussam šŸ‘‹ thanks for sharing this. It actually sounds like a bug to me, would you mind opening an issue with a concrete example so that we can reproduce and fix the problem? (Ideally, you could even share a standalone repo with a reproduction šŸ™)
h
(Ideally, you could even share a standalone repo with a reproduction šŸ™)
I have set up written in the repo. repo link The files you would be searching for schema.prisma (line 35,51) seed script to populate initial data Steps to reproduction: •
npx prisma db seed
•
npx prisma db studio
(observe 9 rows in an event, 11 rows in student_enrollment ) • add this to line 60 of seed.ts just before catch block
Copy code
await prisma.event.delete({
        where: {
          id: 1,
        },
      });
• run the seed command again • event with id 1 is deleted which should delete 2 rows in student_enrollment(id 1 and 2) • Result: 1 row is deleted from event table, no rows are deleted in student_enrollment. I am sure if this is the format you'd expect reproduction, let me if this does not help.
Edit: It seems to work fine at the moment. It's strange though I didn't change anything. There is a slight chance it might be due to
npx prisma db push
command. As I added
onDelete: Cascade
and run the above command , there was not change detected by prisma (somethin like the "already n sync")