fix(comm): handle null tags array in contact creation
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -206,10 +206,11 @@ func (h *ContactHandler) createNewContact(tenantID uuid.UUID, req CreateContactR
|
|||||||
err := h.db.QueryRow(`
|
err := h.db.QueryRow(`
|
||||||
INSERT INTO contacts (tenant_id, first_name, last_name, email, phone, company, source, tags, metadata)
|
INSERT INTO contacts (tenant_id, first_name, last_name, email, phone, company, source, tags, metadata)
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
||||||
RETURNING id, tenant_id, first_name, last_name, email, phone, company, tags, status, lead_score, source, created_at, updated_at
|
RETURNING id, tenant_id, first_name, last_name, email, phone, company, status, lead_score, source, created_at, updated_at
|
||||||
`, tenantID, req.FirstName, req.LastName, req.Email, req.Phone, req.Company, req.Source, req.Tags, metadata).Scan(
|
`, tenantID, req.FirstName, req.LastName, req.Email, req.Phone, req.Company, req.Source,
|
||||||
|
nullStringArray(req.Tags), metadata).Scan(
|
||||||
&contact.ID, &contact.TenantID, &contact.FirstName, &contact.LastName, &contact.Email, &contact.Phone,
|
&contact.ID, &contact.TenantID, &contact.FirstName, &contact.LastName, &contact.Email, &contact.Phone,
|
||||||
&contact.Company, &contact.Tags, &contact.Status, &contact.LeadScore, &contact.Source, &contact.CreatedAt, &contact.UpdatedAt,
|
&contact.Company, &contact.Status, &contact.LeadScore, &contact.Source, &contact.CreatedAt, &contact.UpdatedAt,
|
||||||
)
|
)
|
||||||
|
|
||||||
return &contact, err
|
return &contact, err
|
||||||
@@ -260,3 +261,10 @@ func getTenantID(r *http.Request) uuid.UUID {
|
|||||||
// Fallback: fixed tenant för utveckling
|
// Fallback: fixed tenant för utveckling
|
||||||
return uuid.MustParse("3847477b-3d56-4975-9157-ae8f9ce52aa7")
|
return uuid.MustParse("3847477b-3d56-4975-9157-ae8f9ce52aa7")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func nullStringArray(arr []string) interface{} {
|
||||||
|
if len(arr) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return arr
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user