Skip to content

Commit

Permalink
refactor(values): uses primitive type in protos
Browse files Browse the repository at this point in the history
  • Loading branch information
MStreet3 committed Sep 24, 2024
1 parent b30438b commit 1be7384
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 121 deletions.
4 changes: 1 addition & 3 deletions pkg/values/pb/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ func NewBigIntValue(sign int, bib []byte) *Value {
func NewTime(t time.Time) *Value {
return &Value{
Value: &Value_TimeValue{
TimeValue: &Time{
Time: timestamppb.New(t),
},
TimeValue: timestamppb.New(t),
},
}
}
165 changes: 51 additions & 114 deletions pkg/values/pb/values.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions pkg/values/pb/values.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ message Value {
Decimal decimal_value = 6;
int64 int64_value = 7;
BigInt bigint_value = 9;
Time time_value = 10;
google.protobuf.Timestamp time_value = 10;
}
}

Expand All @@ -34,5 +34,3 @@ message Decimal {
BigInt coefficient = 1;
int32 exponent = 2;
}

message Time { google.protobuf.Timestamp time = 1; }
2 changes: 1 addition & 1 deletion pkg/values/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func FromProto(val *pb.Value) (Value, error) {
case *pb.Value_BigintValue:
return fromBigIntValueProto(val.GetBigintValue()), nil
case *pb.Value_TimeValue:
return NewTime(val.GetTimeValue().Time.AsTime()), nil
return NewTime(val.GetTimeValue().AsTime()), nil
}

return nil, fmt.Errorf("unsupported type %T: %+v", val, val)
Expand Down

0 comments on commit 1be7384

Please sign in to comment.