Skip to content

fix(testing): reset Postgres tables with TRUNCATE so row triggers cannot refuse it (#1052) - #1059

Merged
antosubash merged 5 commits into
mainfrom
fix/test-reset-truncate-1052
Nov 20, 2026
Merged

antosubash merged 5 commits into
mainfrom
fix/test-reset-truncate-1052

Conversation

@antosubash

Copy link
Copy Markdown
Owner

Summary

  • simple_module_test's between-test reset on Postgres now runs one TRUNCATE … RESTART IDENTITY RESTRICT over the model tables instead of a DELETE per table. App BEFORE DELETE row triggers, such as immutable issued records, no longer make every later test error at setup (simple_module_test: between-test table reset uses DELETE, which row triggers can refuse #1052).
  • Behaviour changes:
    • RESTRICT instead of CASCADE: the reset never empties tables outside its list. A foreign key from such a table makes the reset fail loudly.
    • A transaction-local 5 s lock_timeout makes a connection leaked from the previous test fail setup instead of hanging it.
    • Statement-level TRUNCATE triggers still fire; this is documented in docs/testing/fixtures.md.
  • Unowned public sequences are still reset. The unreachable SQLite branch is gone, because SQLite rebuilds the database per test.

Verification

  • Real Postgres (dev-services):
    • framework/testing/tests: 97 passed.
    • Red/green: with database.py reverted, 3 of the reset tests fail.
    • A broad slice (users, tenants, file_storage, background_tasks, framework/db) with -n 8: 3618 passed.
  • Local CI: make lint ✓, make test-js 998 ✓, PYTEST_WORKERS=8 make test-py 9521 passed ✓.
  • After merging fix(mail): send Date and Message-ID; validated custom headers (#1053) #1058 from main: framework/testing + mail tests, 189 passed.
  • /ship: optimize, then 2 review passes (pass 1 fixed CASCADE scope, the lock hang and the dead code; pass 2 clean on both).
  • Report: https://claude.ai/artifact/6iagy2jz2ZAF5eg7qDxkUY

Report links are Claude Artifacts and start private.

Closes #1052

https://claude.ai/code/session_01FXHA3Zj78w6GWaNKoovHq6

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-11-20T16:20:37.224797Z a9be636 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying simple-module-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: a9be636
Status: ✅  Deploy successful!
Preview URL: https://2d8a9594.simple-module-python.pages.dev
Branch Preview URL: https://fix-test-reset-truncate-1052.simple-module-python.pages.dev

View logs

@antosubash antosubash added the shipped /ship passed on the head commit label Nov 20, 2026
@antosubash

Copy link
Copy Markdown
Owner Author

/ship passed on a9be636

@antosubash
antosubash merged commit f391def into main Nov 20, 2026
19 checks passed
@antosubash
antosubash deleted the fix/test-reset-truncate-1052 branch November 20, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shipped /ship passed on the head commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

simple_module_test: between-test table reset uses DELETE, which row triggers can refuse

1 participant