From 01fcd838be9c95d8e322b9f2e5effdc96a64fe2e Mon Sep 17 00:00:00 2001 From: wlinator Date: Tue, 20 Jun 2023 05:37:19 -0400 Subject: [PATCH] Fix exchange bug The bug would occur when any balance is '0', the user's balance would reach the fallback and be reset entirely. This is fixed now. --- data/Currency.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/Currency.py b/data/Currency.py index 6ad050a..f476123 100644 --- a/data/Currency.py +++ b/data/Currency.py @@ -38,7 +38,7 @@ class Currency: query = """ SELECT cash_balance, special_balance FROM currency - WHERE user_id = ? + WHERE user_id = ? """ try: @@ -49,7 +49,7 @@ class Currency: # if the user doesn't have a balance yet -> create one # additionally if for some reason a balance becomes Null # re-generate the user's balance as fallback. - if not cash_balance or not special_balance: + if cash_balance is None or special_balance is None: query = """ INSERT INTO currency (user_id, cash_balance, special_balance) VALUES (?, 50, 3)