提交 c9544e79 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix ResultSet.getObject(*, BigInteger.class) for DECIMAL values

上级 58e4f59f
......@@ -3773,7 +3773,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet, JdbcResultS
if (type == BigDecimal.class) {
return type.cast(value.getBigDecimal());
} else if (type == BigInteger.class) {
return type.cast(BigInteger.valueOf(value.getLong()));
return type.cast(value.getBigDecimal().toBigInteger());
} else if (type == String.class) {
return type.cast(value.getString());
} else if (type == Boolean.class) {
......
......@@ -1152,6 +1152,18 @@ public class TestResultSet extends TestBase {
assertTrue(!rs.next());
stat.execute("DROP TABLE TEST");
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY,VALUE DECIMAL(22,2))");
stat.execute("INSERT INTO TEST VALUES(1,-12345678909876543210)");
stat.execute("INSERT INTO TEST VALUES(2,12345678901234567890.12345)");
rs = stat.executeQuery("SELECT * FROM TEST ORDER BY ID");
rs.next();
assertEquals(new BigDecimal("-12345678909876543210.00"), rs.getBigDecimal(2));
assertEquals(new BigInteger("-12345678909876543210"), rs.getObject(2, BigInteger.class));
rs.next();
assertEquals(new BigDecimal("12345678901234567890.12"), rs.getBigDecimal(2));
assertEquals(new BigInteger("12345678901234567890"), rs.getObject(2, BigInteger.class));
stat.execute("DROP TABLE TEST");
}
private void testDoubleFloat() throws SQLException {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论