fix(contacts): populate company_name via LEFT JOIN to companies #266
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/pms-334-contact-company-name"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
ContactResponse declared company_name but its From impl hardcoded None, and the contact read queries selected FROM contacts with no JOIN, so the Contacts list Company column was always blank and every consumer of the DTO got company_name: null even when company_id was set.
Add company_name to the Contact model and ContactRow, and LEFT JOIN companies (co.id = c.company_id AND co.tenant_id = c.tenant_id) selecting co.name AS company_name in get_contact, list_contacts, and get_company_contacts. The data query in list_contacts qualifies its conditions and ORDER BY with the contacts alias c since companies also exposes tenant_id / status / created_at; the count query keeps no JOIN and stays unqualified. LEFT join so contacts with no company still return with company_name: null and no rows are dropped. ContactResponse::from now maps the resolved value.
Strengthen contact_crud_happy_path to assert company_name is populated on the create response, the list row, and the single-contact GET.
#PMS-334