Skip to content

Commit aab39ff

Browse files
authored
数字转字符串范围优化为 JavaScript 的 Number.MAX_SAFE_INTEGER ~ Number.MIN_SAFE_INTEGER
1 parent 4a2e7f5 commit aab39ff

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

APIJSONORM/src/main/java/apijson/orm/AbstractSQLExecutor.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,10 +1077,14 @@ public Object getNumVal(Number value) {
10771077
}
10781078

10791079
double v = value.doubleValue();
1080-
if (v > Integer.MAX_VALUE || v < Integer.MIN_VALUE) { // 避免前端/客户端拿到精度丢失甚至严重失真的值
1080+
// if (v > Integer.MAX_VALUE || v < Integer.MIN_VALUE) { // 避免前端/客户端拿到精度丢失甚至严重失真的值
1081+
// return value.toString();
1082+
// }
1083+
// JavaScript: Number.MAX_SAFE_INTEGER ~ Number.MIN_SAFE_INTEGER
1084+
if (v > 9007199254740991L || v < -9007199254740991) { // 避免前端/客户端拿到精度丢失甚至严重失真的值
10811085
return value.toString();
10821086
}
1083-
1087+
10841088
return value;
10851089
}
10861090

0 commit comments

Comments
 (0)