fix: Correctly handle query result rows when generating new trading plan ID
This commit is contained in:
parent
0ac499ae8c
commit
d17dc47d42
@ -137,7 +137,8 @@ def save_trading_plan(plan: TradingPlan) -> int:
|
|||||||
if not plan.id:
|
if not plan.id:
|
||||||
# Generate new ID for new plans
|
# Generate new ID for new plans
|
||||||
result = client.query("SELECT max(id) FROM trading_plans")
|
result = client.query("SELECT max(id) FROM trading_plans")
|
||||||
plan.id = (result[0][0] or 0) + 1
|
max_id = result.result_rows[0][0] if result.result_rows else 0
|
||||||
|
plan.id = (max_id or 0) + 1
|
||||||
plan.created_at = datetime.now()
|
plan.created_at = datetime.now()
|
||||||
|
|
||||||
plan.updated_at = datetime.now()
|
plan.updated_at = datetime.now()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user