Skip to content

Commit 92aa6b1

Browse files
authored
MySQL: Unsupported type java.math.BigDecimal (eclipse-vertx#1504)
See eclipse-vertx#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 459283d commit 92aa6b1

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
@@ -20,6 +20,7 @@
2020
import io.vertx.sqlclient.data.Numeric;
2121
import io.vertx.sqlclient.impl.RowBase;
2222

23+
import java.math.BigDecimal;
2324
import java.time.*;
2425
import java.time.temporal.Temporal;
2526
import java.util.List;
@@ -50,6 +51,8 @@ public <T> T get(Class<T> type, int position) {
5051
return type.cast(getFloat(position));
5152
} else if (type == Double.class) {
5253
return type.cast(getDouble(position));
54+
} else if (type == BigDecimal.class) {
55+
return type.cast(getBigDecimal(position));
5356
} else if (type == Numeric.class) {
5457
return type.cast(getNumeric(position));
5558
} else if (type == String.class) {

vertx-mysql-client/src/test/java/io/vertx/tests/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)