Skip to content

Commit b410327

Browse files
committed
MySQL: Unsupported type java.math.BigDecimal (#1504)
See #1473 Since it is possible to retrieve a BigDecimal with getBigDecimal(idx), it should be possible to it as well with get(BigDecimal.class, idx). Signed-off-by: Thomas Segismont <[email protected]>
1 parent bb2b3df commit b410327

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

vertx-mysql-client/src/main/java/io/vertx/mysqlclient/impl/MySQLRowImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import io.vertx.sqlclient.impl.ArrayTuple;
2323
import io.vertx.sqlclient.impl.RowBase;
2424

25+
import java.math.BigDecimal;
2526
import java.time.*;
2627
import java.time.temporal.Temporal;
2728
import java.util.List;
@@ -52,6 +53,8 @@ public <T> T get(Class<T> type, int position) {
5253
return type.cast(getFloat(position));
5354
} else if (type == Double.class) {
5455
return type.cast(getDouble(position));
56+
} else if (type == BigDecimal.class) {
57+
return type.cast(getBigDecimal(position));
5558
} else if (type == Numeric.class) {
5659
return type.cast(getNumeric(position));
5760
} else if (type == String.class) {

vertx-mysql-client/src/test/java/io/vertx/mysqlclient/data/NumericDataTypeTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public void testBinaryEncodeBigDecimal(TestContext ctx) {
5353
ctx.assertEquals(999999999L, row.getLong(columnName));
5454
ctx.assertEquals(BigDecimal.valueOf(999999999L), row.getBigDecimal(columnName));
5555
ctx.assertEquals(BigDecimal.valueOf(999999999L), row.getBigDecimal(columnName));
56+
ctx.assertEquals(BigDecimal.valueOf(999999999L), row.get(BigDecimal.class, columnName));
57+
ctx.assertEquals(BigDecimal.valueOf(999999999L), row.get(BigDecimal.class, columnName));
5658
ctx.assertEquals(Numeric.parse("999999999"), row.getValue(0));
5759
ctx.assertEquals(Numeric.parse("999999999"), row.getValue(columnName));
5860
});

0 commit comments

Comments
 (0)