strongduanmu commented on a change in pull request #14337:
URL: https://github.com/apache/shardingsphere/pull/14337#discussion_r775360812
##########
File path:
shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ResultSetUtil.java
##########
@@ -169,7 +172,7 @@ private static Object convertNumberValue(final Object
value, final Class<?> conv
Number number = (Number) value;
switch (convertType.getName()) {
case "boolean":
- return 0 != number.longValue();
+ return longToBoolean(number.longValue());
Review comment:
@challengeof Why change this logic?
##########
File path:
shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ResultSetUtil.java
##########
@@ -224,4 +227,22 @@ private static Object convertByteArrayValue(final Object
value, final Class<?> c
return value;
}
}
+
+ private static Object convertBooleanValue(final Object value) {
+ if (value instanceof Boolean) {
+ return value;
+ }
+ String stringVal = value.toString();
+ if (stringVal.length() > 0) {
+ int c = Character.toLowerCase(stringVal.charAt(0));
+ return c == 't' || c == 'y' || c == '1' || "-1".equals(stringVal);
Review comment:
@challengeof Can we rename `c` to `firstChar`? And put constant on the
left condition?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]