Family references discriminate through the referenced row's type (+ GUC empty-string guards) #2

Open
satyabhangt wants to merge 1 commits from family-discriminates-through-the-reference into main

1 Commits

Author SHA1 Message Date
f60158564d Family references discriminate through the referenced row's type
Intention: make local <prop>_type columns optional denormalization instead
of an engine requirement — writers should only ever have to say WHO.

Outcomes:
- compile_one_of: a type-strategy family REFERENCE (payer, source, target)
  now selects its polymorphic branch via the referenced row's own type —
  CASE (SELECT type FROM agreego.entity WHERE id = <alias>.<prop>_id) —
  the truth itself, instead of requiring a <prop>_type column beside the
  id. kind-strategy STI and a row's self-discrimination still read locally
  (there is no referenced row to consult). All CASEs are now simple-form,
  so the operand is evaluated once even as a subquery.
- GUC readers guard against the empty string: a rolled-back transaction
  that FIRST-sets a custom GUC leaves it '' session-wide (not unset), and
  COALESCE alone never fires — auth.user_id and punc.external now NULLIF
  first, matching agreego.get_cue's own convention.
- Golden fixtures regenerated via UPDATE_EXPECT; 1286 tests green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-25 18:21:44 -04:00