Skip to content

Updates int32 to int#55

Merged
jlpdeveloper merged 4 commits into
mainfrom
update-db-type
May 8, 2026
Merged

Updates int32 to int#55
jlpdeveloper merged 4 commits into
mainfrom
update-db-type

Conversation

@jlpdeveloper
Copy link
Copy Markdown
Contributor

@jlpdeveloper jlpdeveloper commented May 8, 2026

Description

Code Rabbit Summary

Summary by CodeRabbit

  • Refactor
    • Optimized internal numeric type handling for platform and product identifiers to improve consistency and resource efficiency.
    • Updated database interaction layers and request processing to utilize standardized numeric types throughout platform and product management workflows.

Fixes

Closes #51

Post Deployment Tasks?

…int32` for IDs, align tests, request structs, and SQLC-generated files.
…uding SQLC-generated files, interfaces, tests, request structs, and related methods.
@jlpdeveloper jlpdeveloper added this to the Phase 2: API Endpoints milestone May 8, 2026
@jlpdeveloper jlpdeveloper self-assigned this May 8, 2026
@jlpdeveloper jlpdeveloper added skip-changelog Won't be added to the release notes chore refactor, maintenance, etc. labels May 8, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR implements the type migration from PostgreSQL int32 to Go's native int type across the codebase. The change begins with sqlc configuration overrides, propagates through generated models and query methods, updates HTTP request structures and path validators, and concludes with test fixture updates.

Changes

PostgreSQL int4 to Go int Type Migration

Layer / File(s) Summary
SQLc Configuration
sqlc.yml
Added int4int type overrides for both internal/platform and internal/product SQL generators.
Generated Models
internal/platform/models.gen.go, internal/product/models.gen.go
Updated identifier fields (ID, FlowID, PlatformID) from int32 to int in Flow, FlowStep, Platform, and Product structs.
Query Interfaces
internal/platform/querier.gen.go, internal/product/querier.gen.go
Updated Querier interface methods (DeletePlatform, GetPlatform, UpdatePlatform, DeleteProduct, GetProductById, GetProductsByPlatform, UpdateProduct) to use int for ID parameters and return values instead of int32.
Query Implementations
internal/platform/platforms.sql.gen.go, internal/product/products.sql.gen.go
Updated method signatures and struct field types (CreateProductParams.PlatformID, UpdatePlatformParams.ID, UpdateProductParams.ID/PlatformID) to use int instead of int32.
Request Structures & Path Validation
internal/platform/request.go, internal/product/request.go, internal/path_variable_validator.go
Updated request struct fields and ToParams() method signatures to use int. Changed GetIntFromRequestPath() return type to int and switched from strconv.ParseInt to strconv.Atoi for parsing.
Tests & Mocks
internal/path_variable_validator_test.go, internal/platform/request_test.go, internal/product/request_test.go, internal/platform/handler_test.go, internal/product/handler_test.go
Updated test assertions and mock function signatures to use int for ID and platform parameters; changed test literals from explicit int32() casts to untyped integer values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • service-atlas/products#16: Introduced initial sqlc-generated models and configuration that this PR now updates with int4→int overrides.
  • service-atlas/products#50: Modified GetIntFromRequestPath() helper which this PR updates with the new int return type.
  • service-atlas/products#17: Added platform and product querier/handler code that this PR updates with int-typed signatures.

Poem

🐰 A rabbit hops through types with glee,
Casting int32 to int, wild and free,
No more (int) noise in every line,
Just native ints that work just fine!
✨ Smaller code, clearer intent—
Migration magic, time well spent! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Updates int32 to int' directly and clearly summarizes the main change—a systematic type conversion from int32 to int across the codebase.
Linked Issues check ✅ Passed The PR fully implements all objectives from issue #51: sqlc.yml now contains int4→int override, all generated models and query functions use int, manual casts are removed, and tests are updated accordingly.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #51 objectives. The PR updates sqlc configuration, regenerates models, updates handlers/services, and modifies tests—all within the stated scope of converting int4 to int.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch update-db-type

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jlpdeveloper
Copy link
Copy Markdown
Contributor Author

@coderabitai review

@jlpdeveloper
Copy link
Copy Markdown
Contributor Author

@CodeRabbit review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/path_variable_validator_test.go (1)

59-102: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add unit test for int32/int4 overflow boundary.

The test file lacks coverage for values exceeding math.MaxInt32 (2147483647). With the recent change from int32 to int in the function signature, GetIntFromRequestPath now accepts values like "2147483648" via strconv.Atoi, which would pass to PostgreSQL int4 columns and fail at the database layer instead of being rejected cleanly at validation.

Add a test case to ensure int4 overflow is caught at validation time:

Suggested test case
+       {
+               name:    "Int4 overflow ID",
+               varName: "id",
+               pathVal: "2147483648", // math.MaxInt32 + 1; valid int64 but exceeds PostgreSQL int4
+               want:    0,
+               wantOk:  false,
+       },
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/path_variable_validator_test.go` around lines 59 - 102, Test suite
for GetIntFromRequestPath is missing a case for int32/int4 overflow; add a new
table test entry in TestGetIntFromRequestPath
(internal/path_variable_validator_test.go) with varName "id", pathVal
"2147483648" (or math.MaxInt32+1 as string), want 0 and wantOk false to assert
overflow is rejected by validation rather than accepted by strconv.Atoi; update
the test table alongside the existing cases so the function
GetIntFromRequestPath is exercised for values > math.MaxInt32.
🧹 Nitpick comments (1)
internal/product/handler_test.go (1)

145-240: ⚡ Quick win

Add large-ID boundary test cases for the int migration paths.

These suites validate non-numeric/zero/negative IDs, but they don’t cover oversized positive IDs (e.g., 2147483648) for id and platform_id. Adding those cases would close a key regression gap from the int32int change.

As per coding guidelines, **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request".

Also applies to: 242-326, 328-399, 401-569

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/product/handler_test.go` around lines 145 - 240, Add unit tests for
oversized positive IDs to TestDeleteProduct to cover int boundary/regression
from int32→int; specifically add cases where id is "2147483648" (and similarly
for platform_id in other test suites) and ensure
mockProductQuerier.deleteProductFunc handles or rejects those values (e.g., by
not being called or returning an appropriate error), then assert the handler
(productHandler.DeleteProduct) returns http.StatusBadRequest or the expected
error status; update the tests at the referenced suites (lines ~242-326,
328-399, 401-569) to include analogous large-ID cases so the code paths that
parse and validate IDs are exercised for overflow scenarios.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/path_variable_validator.go`:
- Around line 29-36: GetIntFromRequestPath currently uses strconv.Atoi and only
checks id > 0, allowing values > int4 max which will later fail in the DB;
modify GetIntFromRequestPath to enforce a PostgreSQL int4 upper bound
(2147483647) by either using strconv.ParseInt(val, 10, 32) and rejecting parse
errors/out-of-range results or keep strconv.Atoi and add an explicit check id <=
math.MaxInt32 (2147483647) and return false if it exceeds that limit so requests
with too-large IDs are rejected at validation time.

---

Outside diff comments:
In `@internal/path_variable_validator_test.go`:
- Around line 59-102: Test suite for GetIntFromRequestPath is missing a case for
int32/int4 overflow; add a new table test entry in TestGetIntFromRequestPath
(internal/path_variable_validator_test.go) with varName "id", pathVal
"2147483648" (or math.MaxInt32+1 as string), want 0 and wantOk false to assert
overflow is rejected by validation rather than accepted by strconv.Atoi; update
the test table alongside the existing cases so the function
GetIntFromRequestPath is exercised for values > math.MaxInt32.

---

Nitpick comments:
In `@internal/product/handler_test.go`:
- Around line 145-240: Add unit tests for oversized positive IDs to
TestDeleteProduct to cover int boundary/regression from int32→int; specifically
add cases where id is "2147483648" (and similarly for platform_id in other test
suites) and ensure mockProductQuerier.deleteProductFunc handles or rejects those
values (e.g., by not being called or returning an appropriate error), then
assert the handler (productHandler.DeleteProduct) returns http.StatusBadRequest
or the expected error status; update the tests at the referenced suites (lines
~242-326, 328-399, 401-569) to include analogous large-ID cases so the code
paths that parse and validate IDs are exercised for overflow scenarios.
🪄 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: 5baf7179-ab98-4797-b2a5-a799507b9f30

📥 Commits

Reviewing files that changed from the base of the PR and between a3d607f and fe7a7b8.

📒 Files selected for processing (15)
  • internal/path_variable_validator.go
  • internal/path_variable_validator_test.go
  • internal/platform/handler_test.go
  • internal/platform/models.gen.go
  • internal/platform/platforms.sql.gen.go
  • internal/platform/querier.gen.go
  • internal/platform/request.go
  • internal/platform/request_test.go
  • internal/product/handler_test.go
  • internal/product/models.gen.go
  • internal/product/products.sql.gen.go
  • internal/product/querier.gen.go
  • internal/product/request.go
  • internal/product/request_test.go
  • sqlc.yml

Comment thread internal/path_variable_validator.go
@jlpdeveloper jlpdeveloper merged commit 1c464f1 into main May 8, 2026
3 checks passed
@jlpdeveloper jlpdeveloper deleted the update-db-type branch May 8, 2026 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore refactor, maintenance, etc. skip-changelog Won't be added to the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update postgres int to be standard go int

1 participant