yesodweb / yesodweb/persistent

SQLite deleteCascade does not handle all foreign keys

Open
#909 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haskell
Stars
486
Forks
306
PR merge metrics
No merged PRs in 30d

Description

Hi, I'm trying to use persistent-sqlite and deleteCascade with foreign keys referencing non-primary-key columns.

Here is my example program based on the reproduction template.

When I run the example, deleteCascade correctly deletes rows of tables with foreign keys that reference the username PK column. But it does not delete the rows of tables with foreign keys that reference the non-PK name column.

Is this something that should work with persistent-sqlite? My current workaround is to replace deleteCascade with multiple deleteWhere statements to take care of the related entities.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked example program and reproduce the difference between foreign keys referencing the username primary key and the non-primary-key name column. Trace how persistent-sqlite handles deleteCascade for those cases, then verify that related rows are deleted for both references without relying on multiple deleteWhere statements.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, sqlite
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.