feat(store): add a helper that marks rows as deleted - #1959
Conversation
softDelete(table) builds the update that sets deleted_at on the live rows of a table. Rows that are already deleted are skipped, so they keep their first delete time. Callers add their own filter with Where.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: raystack/frontier/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughThe PostgreSQL store adds a ChangesPostgres soft delete
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~8 minutes Change: Other Suggested reviewers: Merge Risk: ⚪ Minimal · up to No merge-blocking issue is identified; the change is mergeable after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The helper is not yet used by production code, so this change does not show a new reachable deletion path. Future callers will need to restrict which rows they delete. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Hardening Proposals
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
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. Comment |
Coverage Report for CI Build 36546808030Coverage increased (+0.004%) to 52.704%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Summary
Adds
softDelete(table)tointernal/store/postgres/postgres.go, next toliveandfromLive. It builds the update that marks the live rows of a table as deleted.Changes
softDelete(table)buildsUPDATE <table> SET deleted_at = now() WHERE <table>.deleted_at IS NULL.Where. goqu joins it to the live filter with AND.postgres_internal_test.gochecks the exact SQL the helper builds, alone and with a caller's filter. It is in packagepostgresbecause the helper is unexported, andpostgres_test.gois in packagepostgres_test.Technical Details
No repository calls the helper yet. The soft delete changes that follow will use it.
Test Plan
go test ./internal/store/postgres/passesgolangci-lint run ./internal/store/postgres/...reports no issuesSQL Safety
?placeholders,goqu.Ex{}, orgoqu.Record{}— neverfmt.Sprintfor+building a query that gets executed.ToSQL()callers capture and forward params (query, params, err := stmt.ToSQL(); db.…Context(ctx, …, query, params...)). Neverquery, _, err := ….?placeholders inside single-quoted SQL literals ingoqu.L.//nolint:forbidigoor// #nosec G20xannotations.