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>
Resolves a query compilation bug in JSPG where reverse/incoming polymorphic
edges (where edge.forward == false, e.g. pet ➡️ cover_attachment) mistakenly
appended the destination type constraint to the parent query's WHERE clause
(e.g., producing `entity_1.type = 'attachment'` on a pet entity query,
causing it to match 0 rows and return null).
- Modifies `compile_polymorphic_bounds` in `compiler.rs` to only compile
type checks when `edge.forward` is true. For reverse edges, the parent's
type check does not belong on the parent table and is already implicitly
restricted by parent ID joins.
- Updates the `fk_attachment_attachable_entity` relation in the queryer test
fixture to correctly model a two-column polymorphic relation, ensuring
this code path is exercised by the unit test suite.