Skip to content

Commit

Permalink
fix: add missing cast for proto optionals (#1557)
Browse files Browse the repository at this point in the history
Related: #1541
  • Loading branch information
codyoss authored Aug 16, 2024
1 parent aae4a63 commit eb6fb9f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/gengapic/paging.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ func internalPageSizeSetter(p func(s string, a ...interface{}), pageSize *descri
switch pageSize.GetType() {
case descriptorpb.FieldDescriptorProto_TYPE_INT32:
if pageSize.GetProto3Optional() {
p("req.%s = proto.Int32(%s)", cName, setVal)
p("req.%s = proto.Int32(int32(%s))", cName, setVal)
} else {
if setVal != "math.MaxInt32" {
setVal = fmt.Sprintf("int32(%s)", setVal)
Expand All @@ -341,7 +341,7 @@ func internalPageSizeSetter(p func(s string, a ...interface{}), pageSize *descri
}
case descriptorpb.FieldDescriptorProto_TYPE_UINT32:
if pageSize.GetProto3Optional() {
p("req.%s = proto.UInt32(%s)", cName, setVal)
p("req.%s = proto.UInt32(uint32(%s))", cName, setVal)
} else {
p("req.%s = uint32(%s)", cName, setVal)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/gengapic/testdata/method_GetManyThingsOptional.want
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ func (c *fooGRPCClient) GetManyThingsOptional(ctx context.Context, req *mypackag
req.PageToken = proto.String(pageToken)
}
if pageSize > math.MaxInt32 {
req.PageSize = proto.Int32(math.MaxInt32)
req.PageSize = proto.Int32(int32(math.MaxInt32))
} else if pageSize != 0 {
req.PageSize = proto.Int32(pageSize)
req.PageSize = proto.Int32(int32(pageSize))
}
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
Expand Down

0 comments on commit eb6fb9f

Please sign in to comment.