From f05169f99459b16e0014f9de4110338d34de63a3 Mon Sep 17 00:00:00 2001 From: Judy <142618594+jimasuen@users.noreply.github.com> Date: Fri, 29 Nov 2024 17:46:47 +0100 Subject: [PATCH] fix: update select query in get_withdraw_links (#52) --- crud.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/crud.py b/crud.py index b65ba1a..ff75fc1 100644 --- a/crud.py +++ b/crud.py @@ -69,12 +69,21 @@ async def get_withdraw_links( wallet_ids: list[str], limit: int, offset: int ) -> tuple[list[WithdrawLink], int]: q = ",".join([f"'{w}'" for w in wallet_ids]) - links = await db.fetchall( - f""" + + query_str = f""" SELECT * FROM withdraw.withdraw_link WHERE wallet IN ({q}) - ORDER BY open_time DESC LIMIT :limit OFFSET :offset - """, - {"limit": limit, "offset": offset}, + ORDER BY open_time DESC + """ + + if limit > 0: + query_str += """ LIMIT :limit OFFSET :offset""" + query_params = {"limit": limit, "offset": offset} + else: + query_params = {} + + links = await db.fetchall( + query_str, + query_params, WithdrawLink, )