From b33468a43f84e95540cd9bd450fb4d46e6a55431 Mon Sep 17 00:00:00 2001 From: Amritanshu Date: Mon, 4 Aug 2025 14:54:42 +0000 Subject: [PATCH] Fix: Show voucher without kots and iventories would cause an error in show. --- barker/barker/routers/voucher/show.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/barker/barker/routers/voucher/show.py b/barker/barker/routers/voucher/show.py index 8c68eed4..23938448 100644 --- a/barker/barker/routers/voucher/show.py +++ b/barker/barker/routers/voucher/show.py @@ -212,8 +212,19 @@ def from_table( ) ) .unique() - .scalar_one() + .scalar_one_or_none() ) + if item is None: + item = db.execute( + select(Voucher) + .join(Voucher.food_table) + .join(Voucher.customer, isouter=True) + .where(Voucher.id == v) + .options( + contains_eager(Voucher.food_table), + contains_eager(Voucher.customer), + ) + ).scalar_one() if guest is not None: item.customer = guest.customer