Skip to content

Conversation

@bigbes
Copy link
Collaborator

@bigbes bigbes commented Sep 4, 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 requested a review from Copilot September 4, 2025 10:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for the go-option library to generate optional types for Tarantool's custom data types (Arrow, Datetime, Interval, Decimal, and UUID). The generated optional types allow handling nullable values while maintaining proper serialization compatibility with MessagePack.

  • Adds go:generate directives to generate Optional* types using github.com/tarantool/go-option/cmd/gentypes
  • Implements MarshalMsgpack and UnmarshalMsgpack methods for the core types to support the optional wrapper serialization
  • Refactors existing encoder/decoder functions to use the new marshal/unmarshal methods

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
uuid/uuid.go Adds go:generate directive and marshal/unmarshal functions for UUID
uuid/uuid_gen.go Generated OptionalUUID type with msgpack serialization support
uuid/example_test.go Minor import formatting cleanup
decimal/decimal.go Adds go:generate directive, implements MarshalMsgpack/UnmarshalMsgpack methods, refactors existing encoder/decoder
decimal/decimal_gen.go Generated OptionalDecimal type with msgpack serialization support
datetime/datetime.go Adds go:generate directive, implements MarshalMsgpack/UnmarshalMsgpack methods, refactors existing encoder/decoder
datetime/datetime_gen.go Generated OptionalDatetime type with msgpack serialization support
datetime/interval.go Adds go:generate directive, implements MarshalMsgpack/UnmarshalMsgpack methods, refactors existing encoder/decoder
datetime/interval_gen.go Generated OptionalInterval type with msgpack serialization support
arrow/arrow.go Adds go:generate directive and implements MarshalMsgpack/UnmarshalMsgpack methods
arrow/arrow_gen.go Generated OptionalArrow type with msgpack serialization support
Comments suppressed due to low confidence (1)

datetime/interval.go:1

  • The default case and error handling for unsupported field types was removed, but this error handling is still needed to prevent silent failures when encountering unknown field types during deserialization.
package datetime

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}
default:
return fmt.Errorf("unsupported interval field type: %d", fieldType)
ival.Adjust = dtToAdjust[fieldVal]
Copy link

Copilot AI Sep 4, 2025

Choose a reason for hiding this comment

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

Potential index out of bounds error. The code assigns dtToAdjust[fieldVal] without checking if fieldVal exists as a key in the dtToAdjust map, which could cause a panic if an invalid adjust value is received.

Copilot uses AI. Check for mistakes.
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.
@bigbes bigbes force-pushed the bigbes/tntp-3735-generate-optional-extensions branch from deb0854 to cf445e8 Compare September 4, 2025 13:47
@bigbes bigbes closed this Sep 4, 2025
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