# Multi-value fields stored as arrays, not comma-delimited strings

- **Pattern:** `ab-001028` (`directory-listing-schema.content-completeness.multi-value-arrays`)
- **Severity:** low
- **Lifecycle:** active
- **Last modified:** 2026-04-18
- **Canonical URL:** https://auditbuffet.com/patterns/ab-001028
- **License:** CC-BY-4.0 — attribute to AuditBuffet Pattern Catalog (https://auditbuffet.com/patterns/ab-001028)

## Why it matters

Comma-delimited strings cannot be indexed for faceted search, cannot be filtered in SQL without `LIKE '%value%'` scans, and produce false matches (`Parking` matches `No Parking`). Consumer APIs that expect arrays get strings and either crash or display literal `WiFi, Parking, Outdoor Seating` as a single tag. Migrating later requires a string-split backfill that is brittle when values themselves contain commas, and every downstream integration that already parsed the string must be updated simultaneously.

## Severity rationale

Low because the data is recoverable and rarely user-facing in raw form, but it blocks filtering and structured data generation.

## Remediation

Store multi-value fields as native arrays in Postgres (`text[]`) or a relational join table, never as delimited strings. Define them as array types in your Prisma schema at `prisma/schema.prisma` and update API serializers to emit JSON arrays. Migrate existing comma-delimited rows with a one-time SQL job that splits and trims, then drops the old column.

```prisma
model Listing {
  id         String   @id @default(cuid())
  name       String
  categories String[]
  amenities  String[]
}
```

## Detection

- **ID:** `multi-value-arrays`
- **Severity:** `low`
- **What to look for:** List all fields that can contain multiple values (categories, tags, hours, images). For each, check the schema for multi-value fields like categories, amenities, phone numbers, cuisine types, etc. Are they stored as database arrays or strings? Look at JSON responses to see if values are arrays or comma-delimited strings.
- **Pass criteria:** Multi-value fields are stored as arrays in the database and returned as arrays in API responses — 100% of multi-value fields must be stored and rendered as arrays, not comma-separated strings. Report: "X multi-value fields found, all Y use proper array formatting."
- **Fail criteria:** Multi-value fields are stored as comma-delimited strings.
- **Skip (N/A) when:** No multi-value fields exist.
- **Detail on fail:** Example: `"Amenities stored as comma-delimited string 'WiFi, Parking, Outdoor Seating'"`
- **Remediation:** Store multi-value fields as arrays:

  ```prisma
  model Listing {
    id String @id @default(cuid())
    name String
    categories String[]
    amenities String[]
  }
  ```

---

Taxons: data-integrity

HTML version: https://auditbuffet.com/patterns/ab-001028
