fix: add missing AND in dynamic SQL query for orders (#135)

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 <noreply@anthropic.com>
This commit is contained in:
Ben Weeks 2025-12-22 18:40:32 +00:00
parent 17d13dbe6b
commit dba3cf2165

View file

@ -616,7 +616,7 @@ async def get_orders(merchant_id: str, **kwargs) -> list[Order]:
rows: list[dict] = await db.fetchall( rows: list[dict] = await db.fetchall(
f""" f"""
SELECT * FROM nostrmarket.orders 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 ORDER BY event_created_at DESC
""", """,
values, values,
@ -643,7 +643,7 @@ async def get_orders_for_stall(
rows: list[dict] = await db.fetchall( rows: list[dict] = await db.fetchall(
f""" f"""
SELECT * FROM nostrmarket.orders 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 ORDER BY time DESC
""", """,
values, values,