mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-10 15:14:09 +00:00
vmctl influx convert bool to number (#1714)
vmctl: properly convert influx bools into integer representation When using vmctl influx, the import would fail importing boolean fields with: ``` failed to convert value "some".0 to float64: unexpected value type true ``` This converts `true` to `1` and `false` to `0`. Fixes #1709
This commit is contained in:
parent
0e1dbcd039
commit
c0853d4bf8
1 changed files with 6 additions and 0 deletions
|
@ -58,6 +58,12 @@ func toFloat64(v interface{}) (float64, error) {
|
|||
return float64(i), nil
|
||||
case string:
|
||||
return strconv.ParseFloat(i, 64)
|
||||
case bool:
|
||||
if i {
|
||||
return 1, nil
|
||||
} else {
|
||||
return 0, nil
|
||||
}
|
||||
default:
|
||||
return 0, fmt.Errorf("unexpected value type %v", i)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue