Repository navigation
refactor(database): consolidate dialect mappers and ErrUnknownDialect - #1285
Conversation
Post-Ent-migration, the database.Type -> ent dialect-string mapping was duplicated: database.EntDialectFor (documented as shared with the migrate package) had a byte-for-byte copy entDialectFor in pkg/database/migrate/fresh.go, plus a parallel ErrUnknownDialect sentinel. The two goose mappers (gooseStoreDialectFor, gooseDialectFor) also duplicated the same switch. Route the migrate package through the shared database.EntDialectFor and delete the duplicate. Collapse the duplicated ErrUnknownDialect to the single database.ErrUnknownDialect across state.go, adopt.go, and apply.go. Merge the goose mappers: goose.Dialect is a type alias of goose's database.Dialect, so fresh.go now uses the shared gooseDialectFor. Update the client.go doc comments to match reality. Behavior-preserving: no schema, migration, or runtime change. Existing pkg/database and pkg/database/migrate suites stay green; a new database-orm spec requirement records the single-source-of-truth invariant. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
This change is part of the following stack: Change managed by git-spice. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (11)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR consolidates dialect-mapping logic by centralizing it to ChangesDialect Mapper Consolidation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Code Review
This pull request consolidates the database dialect mapping logic and error sentinels across the pkg/database and pkg/database/migrate packages. It removes the duplicate entDialectFor and gooseStoreDialectFor functions in pkg/database/migrate/fresh.go, routing calls to the shared database.EntDialectFor and gooseDialectFor instead. It also eliminates the duplicate ErrUnknownDialect sentinel in the migrate package in favor of a single source of truth (database.ErrUnknownDialect). No review comments were provided, so I have no feedback to evaluate.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1285 +/- ##
============================
============================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Post-Ent-migration cleanup. The
database.Type→ ent dialect-string mapping was duplicated:database.EntDialectFor(documented as shared with the migrate package) had a byte-for-byte copyentDialectForinpkg/database/migrate/fresh.go, plus a parallelErrUnknownDialectsentinel. The two goose mappers (gooseStoreDialectFor,gooseDialectFor) duplicated the same switch.database.EntDialectFor; delete the duplicate (and the now-unusedentgo.io/ent/dialectimport).ErrUnknownDialectto the singledatabase.ErrUnknownDialectacrossstate.go,adopt.go,apply.go.goose.Dialectis a type alias of goose-store'sdatabase.Dialect, sofresh.gouses the sharedgooseDialectFor.database-ormspec requirement for the single-source-of-truth invariant.Test plan
task fmt/task lint(0 issues) /task test(full suite green)pkg/databaseandpkg/database/migratesuites cover dialect mapping + fresh install