Skip to content

Commit 823adcf

Browse files
authored
Additional types to string. (#72)
* Additional types to string. * Fix varbinary * Fix format for big.Float
1 parent ea7bbc0 commit 823adcf

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

voltdbclient/rows.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,15 @@ func (rows VoltRows) GetStringValue(valtype int8, colIndex int16) (string, error
380380
return "0", nil
381381
}
382382
return fmt.Sprintf("%d", i.(int8)), nil
383+
case 4:
384+
i, err := rows.GetSmallInt(colIndex)
385+
if err != nil {
386+
return "", err
387+
}
388+
if i == nil {
389+
return "0", nil
390+
}
391+
return fmt.Sprintf("%d", i.(int16)), nil
383392
case 5:
384393
i, err := rows.GetInteger(colIndex)
385394
if err != nil {
@@ -407,7 +416,38 @@ func (rows VoltRows) GetStringValue(valtype int8, colIndex int16) (string, error
407416
return "0", nil
408417
}
409418
return fmt.Sprintf("%f", i.(float64)), nil
419+
case 11:
420+
t, err := rows.GetTimestamp(colIndex)
421+
if err != nil {
422+
return "", err
423+
}
424+
if t == nil {
425+
return "0", nil
426+
}
427+
return t.(time.Time).String(), nil
428+
case 22:
429+
t, err := rows.GetDecimal(colIndex)
430+
if err != nil {
431+
return "", err
432+
}
433+
if t == nil {
434+
return "0", nil
435+
}
436+
return fmt.Sprintf("%v", t.(big.Float)), nil
437+
case 25:
438+
t, err := rows.GetVarbinary(colIndex)
439+
if err != nil {
440+
return "", err
441+
}
442+
if t == nil {
443+
return "", nil
444+
}
445+
return string(t.([]byte)), nil
446+
}
447+
if valtype != 9 {
448+
return "", errors.New("Unsupported type for GetStringValue")
410449
}
450+
// type 9 is string
411451
s, err := rows.GetString(colIndex)
412452
if err != nil || s == nil {
413453
return "", err

0 commit comments

Comments
 (0)