Null values in columns of type `boolean` are returned as `false`
timo-schluessler opened this issue · comments
Specifications
- Client Version: 1.29.0
- InfluxDB Version: 2.0.7
- Platform: Linux
Code sample to reproduce problem
import { InfluxDB } from '@influxdata/influxdb-client'
const token = '### enter token ###';
const queryApi = new InfluxDB({url: 'http://localhost:8086', token}).getQueryApi('Org');
queryApi.queryRows(
`import "experimental/array"
array.from(rows: [
{_measurement: "m0", _field: "f0", _value: true, _time: 2020-01-01T00:00:00Z,},
{_measurement: "m0", _field: "f1", _value: true, _time: 2020-01-01T00:00:00Z,},
{_measurement: "m0", _field: "f0", _value: true, _time: 2020-01-01T01:00:00Z,},
// no entry for f1 at 01:00:00 -> _value will be set to null by pivot()
])
|> pivot(rowKey: ["_time"], columnKey: ["_field"], valueColumn: "_value")`,
{
next: (row, tableMeta) => {
console.log(`At ${tableMeta.get(row, '_time')} f0 is ${tableMeta.get(row, 'f0')} and f1 is ${tableMeta.get(row, 'f1')}`);
},
error: e => console.log(e),
complete: () => {},
}
);
Expected behavior
At 2020-01-01T00:00:00Z f0 is true and f1 is true
At 2020-01-01T01:00:00Z f0 is true and f1 is null
Actual behavior
At 2020-01-01T00:00:00Z f0 is true and f1 is true
At 2020-01-01T01:00:00Z f0 is true and f1 is false
Additional info
I think this line should be changed to
boolean: (x: string): any => (x === '' ? null : x === 'true'),
Thank you @timo-schluessler for posting an issue and suggesting a fix. I am on it.
This is going to be fixed quickly. If you can't wait, you can change the default serializer the way you propose. default typeSerializers
are exported.
Ok, thanks for your quick reaction.
The fix is available in the nightly build (since version: 1.30.0-nightly.2813), it will become part of the release.