Skip to content

feat!: rename Value[T] to Option[T] — fix driver.Valuer shadow bug#2

Merged
kolkov merged 1 commit into
mainfrom
feat/rename-value-to-option
Jul 5, 2026
Merged

feat!: rename Value[T] to Option[T] — fix driver.Valuer shadow bug#2
kolkov merged 1 commit into
mainfrom
feat/rename-value-to-option

Conversation

@kolkov

@kolkov kolkov commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Breaking: Value[T] renamed to Option[T] — fixes driver.Valuer shadow bug (ADR-003)
  • Breaking: Field.ToValue() renamed to Field.ToOption()
  • New: FieldFromOption[T]() — lossless Option→Field conversion (ADR-002)
  • New: Compile-time interface checks for all 16 concrete types

Why

Go selector rules cause the embedded field name Value (depth 1) to shadow the Value() method from sql.Null[T] (depth 2). All concrete types (String, Int, etc.) failed to implement driver.Valuer. INSERT with pgx/database/sql was broken.

Renaming to Option[T] eliminates the name collision — driver.Valuer now works via natural method promotion on all types.

Test plan

  • go build ./... — clean
  • go test ./... — all pass (opt: 81 tests, zero: 35 tests)
  • go vet ./... — clean
  • Compile-time interface checks verify driver.Valuer on all 16 types
  • Manual verification: String implements driver.Valuer: true

…hecks

BREAKING: Value[T] renamed to Option[T] to fix driver.Valuer shadow bug
where all concrete types failed to implement driver.Valuer due to Go
selector rules (field name 'Value' shadowed method 'Value()' from
sql.Null[T]).

- Rename Value[T] -> Option[T] across opt/ and zero/ (ADR-003)
- Rename Field.ToValue() -> Field.ToOption()
- Add FieldFromOption[T]() lossless upcast (ADR-002)
- Add compile-time interface checks (interfaces_test.go)
- Update all public documentation for v0.3.0
@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
zero/option.go 75.00% 3 Missing ⚠️
zero/bool.go 0.00% 1 Missing ⚠️
zero/byte.go 0.00% 1 Missing ⚠️
zero/float.go 0.00% 1 Missing ⚠️
zero/int.go 0.00% 1 Missing ⚠️
zero/int16.go 0.00% 1 Missing ⚠️
zero/string.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@kolkov kolkov merged commit 4cb5c91 into main Jul 5, 2026
15 checks passed
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.

1 participant