fix: 过滤NaN/nan/null/空值防MySQL报错

This commit is contained in:
yumoqing 2026-06-29 16:58:37 +08:00
parent f14eb4f704
commit 34843b6634

View File

@ -13,6 +13,17 @@ try:
if not discountid or not productid: if not discountid or not productid:
raise Exception('缺少必要参数: discountid, productid') raise Exception('缺少必要参数: discountid, productid')
# 过滤 NaN 和空值
if discount_val is not None:
s = str(discount_val).strip().lower()
if s in ('', 'nan', 'none', 'null'):
discount_val = None
if old_discount is not None:
s = str(old_discount).strip().lower()
if s in ('', 'nan', 'none', 'null'):
old_discount = None
# 对比新旧值,相同则跳过 # 对比新旧值,相同则跳过
if discount_val is not None and old_discount is not None: if discount_val is not None and old_discount is not None:
try: try: