From 30d258063964920de80a17180f37dd67d288380f Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Fri, 12 Jun 2026 16:20:10 -0400 Subject: [PATCH] docs(bootstrap): document prefixed FK table name override pattern Adds a note to the Field Evolution Checklist explaining why poc_person_id and similar prefixed FK fields need an explicit mapping in sanitize_payload(). Co-Authored-By: Claude Sonnet 4.6 --- documentation/BOOTSTRAP__AI_Agent_Quickstart.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/documentation/BOOTSTRAP__AI_Agent_Quickstart.md b/documentation/BOOTSTRAP__AI_Agent_Quickstart.md index 3da5164..0912952 100644 --- a/documentation/BOOTSTRAP__AI_Agent_Quickstart.md +++ b/documentation/BOOTSTRAP__AI_Agent_Quickstart.md @@ -252,6 +252,15 @@ When a table or view gains, loses, or renames fields — **do all of these in or 5. Run the relevant schema/search E2E tests 6. **Restart Docker:** `docker compose restart ae_api` +#### FK fields with non-matching prefixes + +The generic `sanitize_payload()` in `lib_api_crud_v3.py` derives the lookup table name by stripping `_id` from the field name (`event_location_id` → `event_location` ✓). If a field has a prefix that doesn't match the table (`poc_person_id` → would look up `poc_person`, but the table is `person`), the random string reaches the DB as-is and MariaDB throws a 1366 integer error. + +Fix: add a mapping to the special-case block in `sanitize_payload()` (same file, same block as `address_location → address`): +```python +if obj_type_lookup == 'poc_person': obj_type_lookup = 'person' +``` + #### Alt-view fields (in `tbl_alt` only) Some objects have a richer alternate SQL view triggered by `?view=alt`. These fields **must still be declared in the Pydantic model and `searchable_fields`** even if they only