From dba3cf2165c429f4398dfb433a259cee63fd05c4 Mon Sep 17 00:00:00 2001 From: Ben Weeks Date: Mon, 22 Dec 2025 18:40:32 +0000 Subject: [PATCH 1/2] fix: add missing AND in dynamic SQL query for orders (#135) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The get_orders and get_orders_for_stall functions were generating malformed SQL when filtering by additional parameters like public_key. Before: WHERE merchant_id = :merchant_id public_key = :public_key After: WHERE merchant_id = :merchant_id AND public_key = :public_key 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- crud.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crud.py b/crud.py index 17282d7..9b800ec 100644 --- a/crud.py +++ b/crud.py @@ -616,7 +616,7 @@ async def get_orders(merchant_id: str, **kwargs) -> list[Order]: rows: list[dict] = await db.fetchall( f""" SELECT * FROM nostrmarket.orders - WHERE merchant_id = :merchant_id {q} + WHERE merchant_id = :merchant_id {('AND ' + q) if q else ''} ORDER BY event_created_at DESC """, values, @@ -643,7 +643,7 @@ async def get_orders_for_stall( rows: list[dict] = await db.fetchall( f""" SELECT * FROM nostrmarket.orders - WHERE merchant_id = :merchant_id AND stall_id = :stall_id {q} + WHERE merchant_id = :merchant_id AND stall_id = :stall_id {('AND ' + q) if q else ''} ORDER BY time DESC """, values, From 0e8a8d35915bc8417b14ce5424d35893d9155a62 Mon Sep 17 00:00:00 2001 From: Ben Weeks Date: Tue, 23 Dec 2025 12:02:42 +0000 Subject: [PATCH 2/2] fix: line too long in get_orders_for_stall MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extract conditional SQL clause to variable to fix E501 (line > 88 chars) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- crud.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crud.py b/crud.py index 9b800ec..3bec1f2 100644 --- a/crud.py +++ b/crud.py @@ -640,10 +640,11 @@ async def get_orders_for_stall( continue values[field[0]] = field[1] + q_clause = f"AND {q}" if q else "" rows: list[dict] = await db.fetchall( f""" SELECT * FROM nostrmarket.orders - WHERE merchant_id = :merchant_id AND stall_id = :stall_id {('AND ' + q) if q else ''} + WHERE merchant_id = :merchant_id AND stall_id = :stall_id {q_clause} ORDER BY time DESC """, values,