mirror of https://github.com/langgenius/dify.git
add rowcount check
This commit is contained in:
parent
75ccba6e52
commit
71bd20cf73
|
|
@ -61,12 +61,8 @@ class CreditPoolService:
|
|||
TenantCreditPool.quota_used + credits_required <= TenantCreditPool.quota_limit,
|
||||
]
|
||||
stmt = update(TenantCreditPool).where(*where_conditions).values(**update_values)
|
||||
result: CursorResult = session.execute(stmt)
|
||||
session.execute(stmt)
|
||||
session.commit()
|
||||
if result.rowcount == 0:
|
||||
raise QuotaExceededError(
|
||||
f"Insufficient credits. Required: {credits_required}, Available: {pool.remaining_credits}"
|
||||
)
|
||||
except Exception:
|
||||
logger.exception("Failed to deduct credits for tenant %s", tenant_id)
|
||||
raise QuotaExceededError("Failed to deduct credits")
|
||||
|
|
|
|||
Loading…
Reference in New Issue