Skip to content

[Bug] Cascade delete of an extended model item does not delete its base model item #2102

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

Open
ErikDakoda opened this issue Apr 29, 2025 · 0 comments

Comments

@ErikDakoda
Copy link

Description and expected behavior

Cascade delete of an extended model item does not delete its base model item

Environment (please complete the following information):

  • ZenStack version: 2.14.0
  • Prisma version: 6.6.0
  • Database type: Neon PostgreSQL

Steps to reproduce

  1. Visit the sample project at https://sample-todo-nextjs-turbo.vercel.app
  2. Sign in or create an account
  3. Create a list
  4. Add a couple of items to the list
  5. Connect to the database using SQLPro for Postgres or similar tool using the connection string postgres://default:yBn6QUr2gWfA@ep-billowing-sun-751704-pooler.us-east-1.aws.neon.tech:5432/verceldb?sslmode=require
  6. Open the User table, find your email address and copy the associated user id
  7. Execute the following SQL to see the list(s) and todo(s) created (replace [user_id] with yours)
SELECT * FROM "List" RIGHT OUTER JOIN "OwnedItem" ON "List".id = "OwnedItem".id WHERE "OwnedItem"."ownedItemType" = 'List' AND "OwnedItem"."ownerId" = '[user_id]' ORDER BY "OwnedItem"."createdAt" DESC;
SELECT * FROM "Todo" RIGHT OUTER JOIN "OwnedItem" ON "Todo".id = "OwnedItem".id WHERE "OwnedItem"."ownedItemType" = 'Todo' AND "OwnedItem"."ownerId" = '[user_id]' ORDER BY "OwnedItem"."createdAt" DESC;
  1. Back in your browser, use the breadcrumbs to go back to your space
  2. Use the trashcan icon to delete the list
  3. Rerun the above query

Expected result:

The deleted list and its todo items are no longer in the database

Actual result:

The list is deleted correctly from the List table and the OwnedItem table
The list's todo items are deleted correctly from the Todo table, but not from the OwnedItem table

NOTE:

  • In the repo the base model is at packages/@erikdakoda/auth/models/ownedItem.zmodel
  • The extended List model is at packages/@erikdakoda/todo/list.zmodel
  • The extended Todo model is at packages/@erikdakoda/todo/todo.zmodel
@ErikDakoda ErikDakoda changed the title Cascade delete of an extended model item does not delete its base model item [Bug] Cascade delete of an extended model item does not delete its base model item Apr 30, 2025
@ErikDakoda ErikDakoda changed the title [Bug] Cascade delete of an extended model item does not delete its base model item Cascade delete of an extended model item does not delete its base model item Apr 30, 2025
@ErikDakoda ErikDakoda changed the title Cascade delete of an extended model item does not delete its base model item [Bug] Cascade delete of an extended model item does not delete its base model item May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant