diff --git a/sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/util/NumberUtil.java b/sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/util/NumberUtil.java index 87a8baa6d019c..7873358aca1dd 100644 --- a/sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/util/NumberUtil.java +++ b/sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/util/NumberUtil.java @@ -69,6 +69,14 @@ public static int roundHalfUp(final Object obj) { * @return exactly number value and type */ public static Number getExactlyNumber(final String value, final int radix) { + try { + return getBigInteger(value, radix); + } catch (final NumberFormatException ex) { + return new BigDecimal(value); + } + } + + private static Number getBigInteger(final String value, final int radix) { BigInteger result = new BigInteger(value, radix); if (result.compareTo(new BigInteger(String.valueOf(Integer.MIN_VALUE))) >= 0 && result.compareTo(new BigInteger(String.valueOf(Integer.MAX_VALUE))) <= 0) { return result.intValue(); diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/insert.xml b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/insert.xml index 1c8dc3dfd6e04..9a00d0d3d6306 100644 --- a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/insert.xml +++ b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/insert.xml @@ -618,4 +618,16 @@ + + + + + + + + + + + + diff --git a/sharding-sql-test/src/main/resources/sql/dml/insert.xml b/sharding-sql-test/src/main/resources/sql/dml/insert.xml index cff495ae07c82..e310445f07828 100644 --- a/sharding-sql-test/src/main/resources/sql/dml/insert.xml +++ b/sharding-sql-test/src/main/resources/sql/dml/insert.xml @@ -43,4 +43,5 @@ +