Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
1.4.5
-
None
-
Java8
Description
I called PreparedStatement.setObject(Type.BIT, "1"). I expected this value registered true.
But it was actually false .
I find the code at github. I found the next code in AbstractMariaDbPrepareStatement.java:781
public void setObject(final int parameterIndex, final Object obj, final int targetSqlType) throws SQLException { |
...
|
} else if (obj instanceof String) { |
...
|
case Types.BIT: |
setBoolean(parameterIndex, Boolean.valueOf(str));
|
break; |
Types.BIT must be handled as a numeric type than a boolean type but the compatibility is important. So I think the next code is more appropriate.
case Types.BOOLEAN: |
case Types.BIT: |
setBoolean(parameterIndex, Boolean.valueOf("true".equals(str) || !"0".equals(str))); |
break; |
And I tested on MySQL Connector/J. It handled Types.BIT as a numeric type.