Skip to content

docs: explain how to use the Go 1.27 stdlib uuid package via overrides - #4599

Merged
kyleconroy merged 1 commit into
mainfrom
claude/uuid-type-overrides-ls5qp0
Sep 1, 2026
Merged

docs: explain how to use the Go 1.27 stdlib uuid package via overrides#4599
kyleconroy merged 1 commit into
mainfrom
claude/uuid-type-overrides-ls5qp0

Conversation

@kyleconroy

Copy link
Copy Markdown
Collaborator

Go 1.27 added a uuid package to the standard library (#4590). This documents the type overrides that let users adopt it today, ahead of sqlc switching its default UUID type:

overrides:
  - db_type: "uuid"
    go_type: "uuid.UUID"
  - db_type: "uuid"
    nullable: true
    go_type:
      import: "uuid"
      type: "UUID"
      pointer: true

Nullable columns map to *uuid.UUID since the standard library has no NullUUID type. No code changes were needed: the override machinery already parses the stdlib import path, and the existing special-casing in imports.go suppresses the hardcoded github.com/google/uuid import whenever an override renders as uuid.UUID.

Verified end-to-end against PostgreSQL 16 with the generated code compiled under go1.27.0, for both sql packages:

  • pgx/v5 handles the type via its underlying-[16]byte wrap plans (TryFindUnderlyingTypeScanPlan / TryWrapFindUnderlyingTypeEncodePlan).
  • database/sql gained first-class support in Go 1.27: driver.DefaultParameterConverter binds uuid.UUID parameters and convertAssign scans string/[]byte values into uuid.UUID and *uuid.UUID destinations, with nil as NULL.

Round-trips covered v4 and v7 UUIDs plus NULL and non-NULL nullable columns.

No endtoend testdata case is included because generated code importing the stdlib uuid package requires Go 1.27+, and the testdata module builds under the repo's Go 1.26 toolchain. uuid[] array columns were not verified, so the docs make no claims about them.

🤖 Generated with Claude Code

https://claude.ai/code/session_01N9jm9kAWEiXHxg3LGsNP4p


Generated by Claude Code

Go 1.27 added a uuid package to the standard library (#4590). Document
the type overrides that map uuid columns to the new package today:
uuid.UUID for non-nullable columns and *uuid.UUID for nullable ones,
since the standard library has no NullUUID type.

Verified against PostgreSQL 16 with generated code compiled under
Go 1.27.0: both pgx/v5 (via its underlying-[16]byte wrapping) and
database/sql (via the new uuid.UUID conversions in convertAssign and
driver.DefaultParameterConverter) round-trip values and NULLs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N9jm9kAWEiXHxg3LGsNP4p
@kyleconroy
kyleconroy merged commit a461f8a into main Sep 1, 2026
8 checks passed
@kyleconroy
kyleconroy deleted the claude/uuid-type-overrides-ls5qp0 branch September 1, 2026 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants