AMashenkov commented on code in PR #6555:
URL: https://github.com/apache/ignite-3/pull/6555#discussion_r2354854419
##########
modules/jdbc/src/main/java/org/apache/ignite/internal/jdbc/JdbcResultSet.java:
##########
@@ -455,21 +434,23 @@ public boolean getBoolean(int colIdx) throws SQLException
{
return false;
}
- Class<?> cls = val.getClass();
-
- if (cls == Boolean.class) {
+ if ("0".equals(val)) {
+ return false;
+ } else if ("1".equals(val)) {
+ return true;
+ } else if (val instanceof Boolean) {
return ((Boolean) val);
- } else if (val instanceof Number) {
- return ((Number) val).intValue() != 0;
- } else if (cls == String.class || cls == Character.class) {
- try {
- return Integer.parseInt(val.toString()) != 0;
- } catch (NumberFormatException e) {
- throw new SQLException("Cannot convert to boolean: " + val,
SqlStateCode.CONVERSION_FAILED, e);
+ } else if (val instanceof Byte || val instanceof Short || val
instanceof Integer || val instanceof Long) {
Review Comment:
```suggestion
switch(jdbcMeta.getColumnType(colIdx)) {
Types.BOOLEAN: ...
Types.VARCHAR: ...
}
```
I prefer `switch` instead of `if-else` when possible.
It just easier to understand.
--
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]