-
Notifications
You must be signed in to change notification settings - Fork 618
Accept 1/0 for boolean configuration values #2740
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,20 @@ | |
| import org.testng.annotations.Test; | ||
|
|
||
| public class ClickHouseUtilsTest { | ||
| @Test(groups = { "unit" }) | ||
| public void testParseBoolean() { | ||
| Assert.assertFalse(ClickHouseUtils.parseBoolean(null)); | ||
|
|
||
| Assert.assertTrue(ClickHouseUtils.parseBoolean("1")); | ||
| Assert.assertFalse(ClickHouseUtils.parseBoolean("0")); | ||
|
|
||
| Assert.assertTrue(ClickHouseUtils.parseBoolean("true")); | ||
| Assert.assertFalse(ClickHouseUtils.parseBoolean("false")); | ||
|
|
||
| // unrecognized values should be parsed as false | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @chernser shouldn't we throw an exception for unrecognized values?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there is an unrecognized value, then we should also follow the behavior pattern of other configs in this case. For example, the Similarly, If we throw an exception only for
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kailash360 both mentioned settings are not validated but should. Please add throwing exception if boolean value is not what we expect. Thanks! |
||
| Assert.assertFalse(ClickHouseUtils.parseBoolean("yes")); | ||
| } | ||
|
|
||
| @Test(groups = { "unit" }) | ||
| public void testCreateTempFile() throws IOException { | ||
| File f = ClickHouseUtils.createTempFile(null, null); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package com.clickhouse.client.api.data_formats.internal; | ||
|
|
||
| import org.testng.Assert; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| public class ValueConvertersTest { | ||
|
|
||
| @Test | ||
| public void testConvertStringToBoolean() { | ||
| ValueConverters vc = new ValueConverters(); | ||
| Assert.assertTrue(vc.convertStringToBoolean("1")); | ||
| Assert.assertFalse(vc.convertStringToBoolean("0")); | ||
| Assert.assertTrue(vc.convertStringToBoolean("true")); | ||
| Assert.assertFalse(vc.convertStringToBoolean("false")); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this method to client-v2
I suggest utilizing ValueConverters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS: clickhouse-data is an old package that we may deprecate so V2 should minimize dependencies on it. Besides clickhouse-data relates to client-v1 and this method is not used there.