Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null values in columns of type boolean are returned as false #578

Closed
timo-schluessler opened this issue Sep 19, 2022 · 4 comments · Fixed by #579
Closed

Null values in columns of type boolean are returned as false #578

timo-schluessler opened this issue Sep 19, 2022 · 4 comments · Fixed by #579
Labels
bug Something isn't working
Milestone

Comments

@timo-schluessler
Copy link

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'),
@timo-schluessler timo-schluessler added the bug Something isn't working label Sep 19, 2022
@sranka
Copy link
Contributor

sranka commented Sep 19, 2022

Thank you @timo-schluessler for posting an issue and suggesting a fix. I am on it.

@sranka
Copy link
Contributor

sranka commented Sep 19, 2022

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.

@timo-schluessler
Copy link
Author

Ok, thanks for your quick reaction.

@bednar bednar added this to the 1.30.0 milestone Sep 19, 2022
@sranka
Copy link
Contributor

sranka commented Sep 19, 2022

The fix is available in the nightly build (since version: 1.30.0-nightly.2813), it will become part of the release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants