Rework Sql connections, add Products sql classes#42
Conversation
…improved modularity. Migrate shared interfaces to `Store`.
…rPlatformCallHandler` for improved modularity
…latform.Querier` for improved modularity.
📝 WalkthroughWalkthroughThis PR restructures the database layer from a generic package to domain-driven packages by splitting sqlc configuration to generate separate Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@api/product/product.go`:
- Around line 1-7: The ProductHandler struct currently declares a queries field
(type product.Querier) but has no methods, causing an unused field/lint error;
remove the dead field from ProductHandler (delete the queries product.Querier
declaration) until you add real handler methods that need product.Querier, or
alternatively add a constructor/usage if you intend immediate use—update
ProductHandler to have no fields for now and keep the package import of
products/internal/db/product only when you reintroduce queries.
In `@internal/db/product/products.sql.go`:
- Around line 14-24: The INSERT uses separate created_at/updated_at params
causing drift; update the SQL constant createProduct to reuse a single named
parameter (e.g. `@timestamp`) for both created_at and updated_at, and adjust the
generated param struct by replacing CreatedAt and UpdatedAt with a single
Timestamp field (type pgtype.Timestamptz) so CreateProduct/CreateProductParams
reflect the single timestamp parameter used in the query.
In `@queries/products.sql`:
- Around line 1-14: The SQL contracts produce the wrong generated API tags and
must match the CRUD spec: keep GetProductsByPlatform (:many) and GetProductById
(:one) as-is, but change any INSERT/UPDATE/DELETE that return an id to use the
:one result tag so the generated product.Querier exposes a single-row return
type; specifically update the CreateProduct, UpdateProduct, and DeleteProduct
declarations to use :one (not :exec) and ensure UpdateProduct's SET list and
params only include name, description, updated_at (no platform_id) and WHERE id
= `@id`, and CreateProduct continues to accept platform_id, name, description,
created_at, updated_at as separate params.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ebbaf853-1c0d-43d0-b8e1-3d358da68ac2
📒 Files selected for processing (19)
api/platform/create.goapi/platform/get.goapi/platform/platform.goapi/platform/platform_querier.goapi/platform/platform_test.goapi/platform/update.goapi/product/product.gointernal/db/platform/db.gointernal/db/platform/models.gointernal/db/platform/platforms.sql.gointernal/db/platform/querier.gointernal/db/product/db.gointernal/db/product/models.gointernal/db/product/products.sql.gointernal/db/product/querier.gointernal/db/store.goqueries/products.sqlrouter/router.gosqlc.yml
💤 Files with no reviewable changes (1)
- api/platform/platform_querier.go
Description
Code Rabbit Summary
Summary by CodeRabbit
New Features
Refactor
Fixes
Closes #21
Post Deployment Tasks?