mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-19 23:09:18 +01: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
0e2486df56
commit
5416e18007
@ -58,6 +58,12 @@ func toFloat64(v interface{}) (float64, error) {
|
|||||||
return float64(i), nil
|
return float64(i), nil
|
||||||
case string:
|
case string:
|
||||||
return strconv.ParseFloat(i, 64)
|
return strconv.ParseFloat(i, 64)
|
||||||
|
case bool:
|
||||||
|
if i {
|
||||||
|
return 1, nil
|
||||||
|
} else {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return 0, fmt.Errorf("unexpected value type %v", i)
|
return 0, fmt.Errorf("unexpected value type %v", i)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user