feat!: rename Value[T] to Option[T] — fix driver.Valuer shadow bug#2
Merged
Conversation
…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 Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Value[T]renamed toOption[T]— fixesdriver.Valuershadow bug (ADR-003)Field.ToValue()renamed toField.ToOption()FieldFromOption[T]()— lossless Option→Field conversion (ADR-002)Why
Go selector rules cause the embedded field name
Value(depth 1) to shadow theValue()method fromsql.Null[T](depth 2). All concrete types (String, Int, etc.) failed to implementdriver.Valuer. INSERT with pgx/database/sql was broken.Renaming to
Option[T]eliminates the name collision —driver.Valuernow works via natural method promotion on all types.Test plan
go build ./...— cleango test ./...— all pass (opt: 81 tests, zero: 35 tests)go vet ./...— cleandriver.Valueron all 16 typesString implements driver.Valuer: true