Skip to content

Commit

Permalink
Merge pull request #2216 from codefairy08/dev_bug_fixs_2211
Browse files Browse the repository at this point in the history
#2211 bug fixs and add test case
  • Loading branch information
terrymanu authored Apr 16, 2019
2 parents d26e3c3 + 75e71ed commit de98230
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,4 +618,16 @@
<and-condition/>
</or-condition>
</parser-result>
<parser-result sql-case-id="insert_with_double_value">
<tables>
<table name="t_double_test" />
</tables>
<tokens>
<table-token start-index="12" table-name="t_double_test" length="13" />
<insert-values-token begin-position="25" />
</tokens>
<or-condition>
<and-condition/>
</or-condition>
</parser-result>
</parser-result-sets>
1 change: 1 addition & 0 deletions sharding-sql-test/src/main/resources/sql/dml/insert.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@
<!--<sql-case id="insert_on_duplicate_key_update_with_table_identifier" value="INSERT INTO t_order (t_order.order_id, t_order.user_id, t_order.status) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE t_order.status = VALUES(t_order.status)" db-types="MySQL" />-->
<sql-case id="insert_with_geography" value="INSERT INTO t_place(user_new_id, guid, start_point,rule) VALUES (?, ?, ST_GeographyFromText('SRID=4326;POINT('||?||' '||?||')'), ?::jsonb)" db-types="PostgreSQL" />
<sql-case id="insert_with_one_auto_increment_column" value="INSERT INTO t_auto_increment_table values()" db-types="MySQL" />
<sql-case id="insert_with_double_value" value="INSERT INTO t_double_test(test_value) values(1.22)" db-types="MySQL" />
</sql-cases>

0 comments on commit de98230

Please sign in to comment.