Skip to content

Conversation

bigbes
Copy link
Collaborator

@bigbes bigbes commented Sep 8, 2025

Add support for go-option to the arrow, datetime, decimal, and uuid packages. This allows for handling optional values of the Arrow, Datetime, Interval, Decimal, and UUID types.

The following changes have been made:

  • Added go:generate directives to the Arrow, Datetime, Interval, Decimal, and UUID types to generate optional types using github.com/tarantool/go-option/cmd/gentypes.
  • Implemented MarshalMsgpack and UnmarshalMsgpack methods for the Arrow, Datetime, Interval, and Decimal types.
  • Added marshalUUID and unmarshalUUID functions for the UUID type.
  • The generated _gen.go files contain the Optional* types that wrap the original types and provide methods to handle optional values, including EncodeMsgpack and DecodeMsgpack for msgpack serialization.
  • Refactored the datetime and decimal decoders to use the new UnmarshalMsgpack methods.

Closes #TNTP-3735.

@bigbes bigbes force-pushed the bigbes/tntp-3735-generate-optional-extensions branch from e3ed24c to 913ab89 Compare September 8, 2025 13:36
@bigbes bigbes marked this pull request as draft September 8, 2025 13:42
@bigbes
Copy link
Collaborator Author

bigbes commented Sep 8, 2025

Converted to draft until go-option v1.0.0 is released.

@bigbes bigbes force-pushed the bigbes/tntp-3735-generate-optional-extensions branch from 913ab89 to 9e1d51b Compare September 9, 2025 10:27
@bigbes bigbes marked this pull request as ready for review September 9, 2025 10:31
@bigbes bigbes force-pushed the bigbes/tntp-3735-generate-optional-extensions branch from 9e1d51b to c45b36a Compare September 9, 2025 12:03
Copy link
Collaborator

@oleg-jukovec oleg-jukovec left a comment

Choose a reason for hiding this comment

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

Thank you for the patch.

Tests are missing, we need tests for new functionality in the public API.

arrow/arrow.go Outdated
Comment on lines 31 to 40
func (a Arrow) MarshalMsgpack() ([]byte, error) {
return a.data, nil
}

func (a *Arrow) UnmarshalMsgpack(data []byte) error {
a.data = data
return nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please, add comments to the public API methods.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 186 to 188

func (d Datetime) MarshalMsgpack() ([]byte, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The same.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 218 to 221

func (d *Datetime) UnmarshalMsgpack(data []byte) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

etc

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

@bigbes bigbes force-pushed the bigbes/tntp-3735-generate-optional-extensions branch from 64ac6f6 to ae84793 Compare September 16, 2025 12:11
@bigbes bigbes requested a review from oleg-jukovec September 16, 2025 12:12
@bigbes
Copy link
Collaborator Author

bigbes commented Sep 16, 2025

macOS tests won't work for now (will be fixed by #462)

Add support for `go-option` to the `arrow`, `datetime`, `decimal`, and `uuid`
packages. This allows for handling optional values of the `Arrow`, `Datetime`,
`Interval`, `Decimal`, `UUID` and `BoxError` types.

The following changes have been made:
- Added `go:generate` directives to the `Arrow`, `Datetime`, `Interval`,
  `Decimal`, `UUID` and `BoxError` types to generate optional types using
  `github.com/tarantool/go-option/cmd/gentypes`.
- Implemented `MarshalMsgpack` and `UnmarshalMsgpack` methods for the `Arrow`,
  `Datetime`, `Interval`, and `Decimal` types.
- Added `marshalUUID` and `unmarshalUUID` functions for the `UUID` type.
- The generated `_gen.go` files contain the `Optional*` types that wrap the
  original types and provide methods to handle optional values, including
  `EncodeMsgpack` and `DecodeMsgpack` for `msgpack` serialization.
- Refactored the `datetime` and `decimal` decoders to use the new
  `UnmarshalMsgpack` methods.
@bigbes bigbes force-pushed the bigbes/tntp-3735-generate-optional-extensions branch from ae84793 to 2cb114b Compare September 16, 2025 12:19
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