From 5acfe4bfc489c5da93f169f05e99151879c5cf0a Mon Sep 17 00:00:00 2001 From: "Bobby (aider)" Date: Tue, 11 Feb 2025 18:25:02 -0800 Subject: [PATCH] fix: Correctly handle query results in trading plan retrieval functions --- src/trading/trading_plan.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/trading/trading_plan.py b/src/trading/trading_plan.py index 9ffc30d..e917bf6 100644 --- a/src/trading/trading_plan.py +++ b/src/trading/trading_plan.py @@ -209,10 +209,12 @@ def get_trading_plan(plan_id: int) -> Optional[TradingPlan]: SELECT * FROM trading_plans WHERE id = %(id)s """, {'id': plan_id}) - if not result: + rows = result.result_rows + + if not rows: return None - plan = result[0] + plan = rows[0] return TradingPlan( id=plan[0], plan_name=plan[1], @@ -267,7 +269,7 @@ def get_all_trading_plans(status: Optional[PlanStatus] = None) -> List[TradingPl query += " ORDER BY updated_at DESC" results = client.query(query, params) - rows = results.result_rows # Ensure this is the correct method to access rows + rows = results.result_rows return [TradingPlan( id=row[0], plan_name=row[1],