Conversation
…ct handling duplication Adds two BaseRepository helpers: - upsert(table, values, target, updateSet) — onConflictDoUpdate (SQLite/PG) vs onDuplicateKeyUpdate (MySQL) - insertIgnore(table, values) — onConflictDoNothing (SQLite/PG) vs try/catch (MySQL) Replaces 10 instances of database-type branching across 7 files: - settings.ts: setSetting, setSettings (2) - ignoredNodes.ts: addIgnoredNodeAsync (1) - misc.ts: upsertSolarEstimate, addAutoTracerouteNode, addAutoTimeSyncNode (3) - nodes.ts: upsertNode (1) - notifications.ts: saveSubscription (1) - auth.ts: setSession (1) - messages.ts: insertMessage (1) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job Pull Request Review ✅Excellent refactor that effectively eliminates database conflict handling duplication through well-designed helper methods. Code Quality & Best Practices ⭐Strengths:
Usage patterns look correct:
Architecture Assessment ✅Excellent design decisions:
Potential Issues 🔍Minor considerations:
Security & Performance ✅No security concerns:
Performance benefits:
Test Coverage 📊Test status: PR description reports 3061 tests pass, 0 failures. The refactor:
Recommendation: The existing test coverage should be sufficient since this is purely an internal refactor. SummaryThis is a high-quality refactor that:
Minor suggestion: Consider more specific error handling in MySQL Recommendation: ✅ Approve - This refactor significantly improves code maintainability with no functional impact. |
Summary
Phase 3 of the Drizzle refactor — adds two BaseRepository helpers that abstract away the
onConflictDoUpdatevsonDuplicateKeyUpdateandonConflictDoNothingvs try/catch differences between database backends.New helpers
upsert(table, values, target, updateSet).insert(table).values(v).onConflictDoUpdate({ target, set: updateSet }).insert(table).values(v).onDuplicateKeyUpdate({ set: updateSet })insertIgnore(table, values).insert(table).values(v).onConflictDoNothing()10 call sites simplified
settings.tssetSettingsettings.tssetSettingsignoredNodes.tsaddIgnoredNodeAsyncmisc.tsupsertSolarEstimatemisc.tsaddAutoTracerouteNodemisc.tsaddAutoTimeSyncNodenodes.tsupsertNodenotifications.tssaveSubscriptionauth.tssetSessionmessages.tsinsertMessageNot changed
notifications.tsbulk mark-as-read methods (raw SQL with structural differences between backends)notifications.tssaveUserPreferences(SQLite has different column set)telemetry.ts/traceroutes.tsDELETE patterns (.returning()issue — future phase)Files Changed
src/db/repositories/base.tsupsert()andinsertIgnore()helperssrc/db/repositories/settings.tssrc/db/repositories/ignoredNodes.tssrc/db/repositories/misc.tssrc/db/repositories/nodes.tssrc/db/repositories/notifications.tssrc/db/repositories/auth.tssrc/db/repositories/messages.tsTest plan
🤖 Generated with Claude Code