mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 17:30:23 +08:00
fix: 修复钱包迁移脚本 _to_decimal 遇到 NaN/Infinity 值时的 InvalidOperation 异常
This commit is contained in:
@@ -53,7 +53,10 @@ def _index_exists(table_name: str, index_name: str) -> bool:
|
|||||||
def _to_decimal(value: object | None) -> Decimal:
|
def _to_decimal(value: object | None) -> Decimal:
|
||||||
if value is None:
|
if value is None:
|
||||||
return Decimal("0")
|
return Decimal("0")
|
||||||
return Decimal(str(value)).quantize(_MONEY_QUANT, rounding=ROUND_HALF_UP)
|
d = Decimal(str(value))
|
||||||
|
if d.is_nan() or d.is_infinite():
|
||||||
|
return Decimal("0")
|
||||||
|
return d.quantize(_MONEY_QUANT, rounding=ROUND_HALF_UP)
|
||||||
|
|
||||||
|
|
||||||
# NUMERIC(20, 8) -> 整数部分最多 12 位 -> 绝对值上限
|
# NUMERIC(20, 8) -> 整数部分最多 12 位 -> 绝对值上限
|
||||||
|
|||||||
Reference in New Issue
Block a user