Skip to content

Conversation

frenchi
Copy link

@frenchi frenchi commented Aug 27, 2025

Introduce nullable.Value[T] as the preferred tri-state JSON field type (unspecified, null, value). Keep nullable.Nullable[T] for compatibility and mark it as deprecated.

  • Add Value[T] with full method set (Get, MustGet, Set, SetNull, etc.)
  • Add constructors: NewValue and NewNullValue
  • Deprecate: NewNullableWithValue, NewNullNullable
  • Update README to prefer Value and add migration notes
  • Add tests mirroring Nullable behavior for Value and constructors

Note: Implemented Value as a separate generic type (not an alias) for Go 1.20 compatibility.

Deprecated:

  • Nullable[T] (use Value[T])
  • NewNullableWithValue (use NewValue)
  • NewNullNullable (use NewNullValue)

Introduce nullable.Value[T] as the preferred tri-state JSON field type
(unspecified, null, value). Keep nullable.Nullable[T] for compatibility
and mark it as deprecated.

- Add Value[T] with full method set (Get, MustGet, Set, SetNull, etc.)
- Add constructors: NewValue and NewNullValue
- Deprecate: NewNullableWithValue, NewNullNullable
- Update README to prefer Value and add migration notes
- Add tests mirroring Nullable behavior for Value and constructors

Note: Implemented Value as a separate generic type (not an alias) for Go 1.20 compatibility.

Deprecated:
- Nullable[T] (use Value[T])
- NewNullableWithValue (use NewValue)
- NewNullNullable (use NewNullValue)
@frenchi frenchi requested a review from a team as a code owner August 27, 2025 07:06
@jamietanna
Copy link
Member

Thanks, this will close #3

(I'll try and take a look at this PR in the next couple of weeks)

@frenchi
Copy link
Author

frenchi commented Aug 27, 2025

Thanks, this will close #3

(I'll try and take a look at this PR in the next couple of weeks)

Thank you, I went digging for the issue reference but you beat me to it! No rush on reviewing this, thanks for your attention.

frenchi added a commit to frenchi/oapi-codegen that referenced this pull request Aug 27, 2025
- Switch generator to output nullable.Value[T] for nullable fields
- Update schema tests to expect Value[T]
- Update README to prefer nullable.Value with migration notes
- Do not edit generated fixtures; regeneration will follow after library update

Notes:
- Requires nullable library release containing Value[T]
- Regenerate test fixtures after bumping dependency

Refs: oapi-codegen/nullable#21
Pending: oapi-codegen/nullable#21
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