Skip to content

Commit e01f9df

Browse files
authored
Use ParseChangesetSpecExternalID from lib (#631)
Has been moved there, but not yet replaced in src cli.
1 parent 17aa10d commit e01f9df

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

internal/batches/executor/coordinator.go

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package executor
22

33
import (
44
"context"
5-
"reflect"
6-
"strconv"
75
"time"
86

97
"github.com/cockroachdb/errors"
@@ -261,27 +259,14 @@ func (c *Coordinator) Execute(ctx context.Context, tasks []*Task, spec *batchesl
261259
}
262260

263261
for _, id := range ic.ExternalIDs {
264-
var sid string
265-
266-
switch tid := id.(type) {
267-
case string:
268-
sid = tid
269-
case int, int8, int16, int32, int64:
270-
sid = strconv.FormatInt(reflect.ValueOf(id).Int(), 10)
271-
case uint, uint8, uint16, uint32, uint64:
272-
sid = strconv.FormatUint(reflect.ValueOf(id).Uint(), 10)
273-
case float32:
274-
sid = strconv.FormatFloat(float64(tid), 'f', -1, 32)
275-
case float64:
276-
sid = strconv.FormatFloat(tid, 'f', -1, 64)
277-
default:
278-
return nil, nil, batcheslib.NewValidationError(errors.Errorf("cannot convert value of type %T into a valid external ID: expected string or int", id))
262+
sid, err := batcheslib.ParseChangesetSpecExternalID(id)
263+
if err != nil {
264+
return nil, nil, err
279265
}
280266

281267
specs = append(specs, &batcheslib.ChangesetSpec{
282268
BaseRepository: repo.ID,
283-
284-
ExternalID: sid,
269+
ExternalID: sid,
285270
})
286271
}
287272
}

0 commit comments

Comments
 (0)