From d2c7a8a624f46d27879751e73165efdf2d67e236 Mon Sep 17 00:00:00 2001 From: Christian Date: Mon, 22 Dec 2025 16:04:49 +0100 Subject: [PATCH] =?UTF-8?q?Fix:=20SQL=20ambiguous=20column=20error=20i=20c?= =?UTF-8?q?ontacts=20s=C3=B8gning=20-=20prefikseret=20med=20c.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/contacts/backend/router_simple.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/contacts/backend/router_simple.py b/app/contacts/backend/router_simple.py index 73e1701..c45fbc1 100644 --- a/app/contacts/backend/router_simple.py +++ b/app/contacts/backend/router_simple.py @@ -74,17 +74,17 @@ async def get_contacts( params = [] if search: - where_clauses.append("(first_name ILIKE %s OR last_name ILIKE %s OR email ILIKE %s)") + where_clauses.append("(c.first_name ILIKE %s OR c.last_name ILIKE %s OR c.email ILIKE %s)") params.extend([f"%{search}%", f"%{search}%", f"%{search}%"]) if is_active is not None: - where_clauses.append("is_active = %s") + where_clauses.append("c.is_active = %s") params.append(is_active) where_sql = "WHERE " + " AND ".join(where_clauses) if where_clauses else "" - # Count total - count_query = f"SELECT COUNT(*) as count FROM contacts {where_sql}" + # Count total (needs alias c for consistency) + count_query = f"SELECT COUNT(*) as count FROM contacts c {where_sql}" count_result = execute_query(count_query, tuple(params)) total = count_result[0]['count'] if count_result else 0