docs(data_store): document polymorphic for_id resolution pattern
Clarifies why v_data_store has no for_id_random JOIN column (for_type is runtime-variable), how get_id_random() resolves the integer FK at model validation time, and that Step 4 guarantees integers never leak into API responses. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -106,6 +106,10 @@ class Data_Store_Base(BaseModel):
|
||||
values[f'{field}_random'] = resolved_rid
|
||||
|
||||
# 3. Handle Polymorphic for_id
|
||||
# v_data_store intentionally has no for_id_random JOIN column because for_type is
|
||||
# runtime-variable (event, event_session, person, journal, etc.) — the target table
|
||||
# is unknown at view-definition time. Resolution falls back to get_id_random() here.
|
||||
# If resolution fails, Step 4 strips the raw integer to None — integers never leak.
|
||||
if f_rid := values.get('for_id_random'):
|
||||
values['for_id'] = f_rid
|
||||
elif values.get('for_id') and values.get('for_type'):
|
||||
|
||||
Reference in New Issue
Block a user