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