From ecb4777a3523d7d81d87dc31d502a2428ed84b20 Mon Sep 17 00:00:00 2001 From: Claude Agent Date: Mon, 16 Mar 2026 19:18:21 +0000 Subject: [PATCH] fix(sqlite): update customer_name on upsert, not just on insert customer_name was only set on INSERT but not updated on ON CONFLICT, so re-synced orders kept the old (wrong) customer name. Co-Authored-By: Claude Opus 4.6 (1M context) --- api/app/services/sqlite_service.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/app/services/sqlite_service.py b/api/app/services/sqlite_service.py index e96d1d9..682e458 100644 --- a/api/app/services/sqlite_service.py +++ b/api/app/services/sqlite_service.py @@ -65,6 +65,7 @@ async def upsert_order(sync_run_id: str, order_number: str, order_date: str, delivery_cost, discount_total) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(order_number) DO UPDATE SET + customer_name = excluded.customer_name, status = CASE WHEN orders.status = 'IMPORTED' AND excluded.status = 'ALREADY_IMPORTED' THEN orders.status @@ -133,6 +134,7 @@ async def save_orders_batch(orders_data: list[dict]): delivery_cost, discount_total) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(order_number) DO UPDATE SET + customer_name = excluded.customer_name, status = CASE WHEN orders.status = 'IMPORTED' AND excluded.status = 'ALREADY_IMPORTED' THEN orders.status