downgrade BigDecimal to Long automatically
This commit is contained in:
parent
fdc3fcd3e2
commit
1a8cf5d8da
2 changed files with 6 additions and 2 deletions
|
@ -1,3 +1,3 @@
|
|||
group = org.xbib
|
||||
name = database
|
||||
version = 2.5.0
|
||||
version = 2.6.0
|
||||
|
|
|
@ -548,7 +548,7 @@ public class DatabaseImpl implements Database {
|
|||
case "java.sql.Time" -> row.add(rows.getLocalTimeOrNull(i + 1));
|
||||
case "oracle.sql.TIMESTAMPTZ" -> row.add(rows.getOffsetDateTimeOrNull(i + 1));
|
||||
case "java.sql.Timestamp", "oracle.sql.TIMESTAMP" -> row.add(rows.getLocalDateTimeOrNull(i + 1));
|
||||
case "java.math.BigDecimal" -> row.add(rows.getBigDecimalOrNull(i + 1));
|
||||
case "java.math.BigDecimal" -> row.add(maybeLong(rows.getBigDecimalOrNull(i + 1)));
|
||||
default -> throw new DatabaseException("unexpected column class name: " + className);
|
||||
}
|
||||
}
|
||||
|
@ -556,6 +556,10 @@ public class DatabaseImpl implements Database {
|
|||
return row;
|
||||
}
|
||||
|
||||
private Number maybeLong(BigDecimal bigDecimal) {
|
||||
return bigDecimal != null && bigDecimal.scale() <= 0 ? bigDecimal.longValue() : bigDecimal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQueue(String table, String channel, String data, Consumer<Long> consumer) throws SQLException {
|
||||
writeNextIntoQueue(connection, table, channel, data, consumer);
|
||||
|
|
Loading…
Reference in a new issue