Skip to content

Add test: transform does not cascade-delete referencing records#792

Merged
simonw merged 2 commits into
mainfrom
claude/transform-cascade-delete-test-otfsu5
Jul 12, 2026
Merged

Add test: transform does not cascade-delete referencing records#792
simonw merged 2 commits into
mainfrom
claude/transform-cascade-delete-test-otfsu5

Conversation

@simonw

@simonw simonw commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Add a test that covers what happens if you run transform against a table with ON CASCADE DELETE for one of its foreign keys - those records should not be deleted during the transform even though the table is dropped as part of that procedure

Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01StxDiBxEbsv8VBmqxamgUV


📚 Documentation preview 📚: https://sqlite-utils--792.org.readthedocs.build/en/792/

Covers running transform against a table involved in an ON DELETE
CASCADE foreign key relationship while PRAGMA foreign_keys is on.
Dropping the old table during transform must not trigger the cascade
and delete records from the referencing table.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01StxDiBxEbsv8VBmqxamgUV
@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.55%. Comparing base (3f04717) to head (8ca780c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #792   +/-   ##
=======================================
  Coverage   95.55%   95.55%           
=======================================
  Files           9        9           
  Lines        3798     3798           
=======================================
  Hits         3629     3629           
  Misses        169      169           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01StxDiBxEbsv8VBmqxamgUV
@simonw simonw merged commit d714200 into main Jul 12, 2026
106 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds regression coverage for sqlite_utils.Table.transform() to ensure that transforming (drop/recreate/rename) a table does not trigger unintended ON DELETE CASCADE behavior that would delete rows in referencing tables when PRAGMA foreign_keys is enabled.

Changes:

  • Adds a new parametrized test that exercises transform() with PRAGMA foreign_keys both disabled and enabled.
  • Validates that transforming a referenced (“parent”) table does not cascade-delete rows in the referencing (“child”) table.
  • Confirms that data remains intact across transforms for both involved tables under the cascade foreign key setup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Successfully merging this pull request may close these issues.

3 participants