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

Fix numeric to bool conversion in converter #7579

Merged
merged 1 commit into from
May 26, 2020

Conversation

aakso
Copy link
Contributor

@aakso aakso commented May 26, 2020

A type switch case with multiple conditions causes the value to remain as
interface which causes toBool to always return true for any numeric values. Looking at the code this doesn't seem to be the desired behavior.

This PR treats all non-zero values as true as it seem to have been the intention
of the original code. This is inconsistent compared to conversion from string which uses strconv.ParseBool. However, making it consistent would probably break things as the unit tests have test cases for positive values that are greater than 1.

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

A type switch case with multiple conditions causes the value to remain as
interface which causes toBool to always return true for any numeric values.
@danielnelson danielnelson added this to the 1.14.4 milestone May 26, 2020
@danielnelson danielnelson added the fix pr to fix corresponding bug label May 26, 2020
@danielnelson danielnelson merged commit ad97b74 into influxdata:master May 26, 2020
danielnelson pushed a commit that referenced this pull request May 26, 2020
A type switch case with multiple conditions causes the value to remain as
interface which causes toBool to always return true for any numeric values.

(cherry picked from commit ad97b74)
jaecktec pushed a commit to jaecktec/telegraf that referenced this pull request Jun 8, 2020
A type switch case with multiple conditions causes the value to remain as
interface which causes toBool to always return true for any numeric values.
rhajek pushed a commit to bonitoo-io/telegraf that referenced this pull request Jul 13, 2020
A type switch case with multiple conditions causes the value to remain as
interface which causes toBool to always return true for any numeric values.
idohalevi pushed a commit to idohalevi/telegraf that referenced this pull request Sep 29, 2020
A type switch case with multiple conditions causes the value to remain as
interface which causes toBool to always return true for any numeric values.
arstercz pushed a commit to arstercz/telegraf that referenced this pull request Mar 5, 2023
A type switch case with multiple conditions causes the value to remain as
interface which causes toBool to always return true for any numeric values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix pr to fix corresponding bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants