Repository navigation
refactor(database): a one-table purge is written as its table and condition - #583
Merged
Merged
Conversation
Fifteen of cleanup's 24 statements delete a batch of one table's rows
that match a condition, each spelling out the same nine-line statement.
`purge!("table" where "condition")` writes it, and the joined
statements stay as they were.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 53 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
PiquelChips
marked this pull request as ready for review
November 20, 2026 09:18
PiquelChips
marked this pull request as draft
November 21, 2026 14:00
PiquelChips
marked this pull request as ready for review
November 21, 2026 14:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #544.
MaintenanceRepository::purge_expired_auth_stateruns 24 delete statements. Fifteen of them delete a batch of one table's rows matching a condition, and each wrote out the same nine-line statement:DELETE FROM t WHERE ctid IN (SELECT ctid FROM t WHERE … LIMIT $1 FOR UPDATE SKIP LOCKED)purge!("table" where "condition")now writes that statement. The nine statements that join or alias keep their full SQL. The function adds up what each statement removed intopurged, so each statement is its ownpurge!call and the comments stay next to the statement they explain.Behavior. The statements are the same as before and run in the same order, and the first error still returns early.
Proof. 15 rewritten queries. In
just db scratch, all 15 pair by identical generic plan and SQLx describe.Tests. No test was merged or removed, and no file outside
crates/databasechanged.Checks:
just fmt;cargo clippy -p sourceorigin-repository --all-targetswith and without--all-features(-D warnings);cargo doc(-D warnings); doc tests;just rust unused;just db prepare.just db test: 497 of 497 pass, and its cache check passes.Note
Written by Claude Opus 5.5 in Claude Code and reviewed by Claude Opus 5.5 (via T3 Code)