fix(contacts): populate company_name via LEFT JOIN to companies #266

Merged
vas2000-work merged 1 commit from fix/pms-334-contact-company-name into main 2026-06-16 23:50:43 +02:00
Owner

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

ContactResponse declared company_name but its From<Contact> 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
fix(contacts): populate company_name via LEFT JOIN to companies
All checks were successful
Check / fmt + clippy + compile + unit/doc tests (pull_request) Successful in 54s
E2E / Playwright against staging (pull_request) Successful in 1m57s
Integration / integration tests (pull_request) Successful in 6m21s
Create release / Create release from merged PR (pull_request) Has been skipped
27ddca3c4f
ContactResponse declared company_name but its From<Contact> 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
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-server!266
No description provided.