Embedded child region: 1. fk-eq filter operator
Storage-column compare for FK fields — [["<type>","<fk-field>","fk-eq","<row-uuid>"]] — the one new query primitive; the region (3) and the post scope (4) both consume it. Backend only: the inert (:fk-eq "fk-eq") arm in operator-sql (the :has-all precedent, never emitted as SQL text), the storage-column case in add-where-clause, a valid-filter arm running before the generic type check (uuid values only — nil, :null, and display names rejected; :target field with no :join-table; table-key must equal the listed type), the measure-path reject before the operator-sql splice, and the docs/rest.md Filter operators list. No rest.lisp edit. Independently testable; the fixture can be a tiny posts/comments pair with no :children declaration.
Amended 2026-11-01 after plan review: the add-where-clause condition column is the table-qualified physical storage column (rt_comments.comment_post), resolved from the compiled view's :columns metadata (the first table-column value at (u:tree-get *compiled-model* type-key :views :main :columns type-key field-key)), with the raw uuid bound directly and never through db-value — not the select-list output alias / target-storage-alias-key. filters-require-join-p stays nil for a listed-type row.
Implemented per the plan (all three review amendments). predicates.lisp: the inert operator-sql arm and the string-shaped :fk-eq case in filter-value-type-p (shape only — uuid-p semantics live in valid-filter; the boolean-declared FK hazard is pinned by a fixture probe). backend.lisp: fk-eq-condition-column (the :columns-metadata lookup) + the :fk-eq arm in add-where-clause (qualified physical column, = "= $N", raw bind, never =db-value), the valid-filter arm beside :has-all (singular-target-field-p + uuid-p; completes validation, skips the generic type check), valid-filters' optional :type-key (cross-type :fk-eq rejected naming both types; guards at be-list, be-id, be-update, be-delete, be-list-column, and update-roles — direct callers unaffected), and the measure-request-grain-filters arm before both the generic classifier and the operator-sql splice. docs/rest.md documents the tuple. Fixture models/test/fk-eq-test.lisp (posts/comments + :crosspost second FK, boolean :flag FK, M2M :tags; comment :title identity so today's valid-target compiles the joiner) seeded via be-set-field-value; suite tests/fk-eq-tests.lisp (46 checks: SQL text on base/join/view SQL, two-filter placeholder alignment, raw-bind pin, storage matches with the title-collision probe, unknown-uuid empty, two-FK column distinctness, guards, rejections, predicate split, (eq :fk-eq (parse-operator "fk-eq"))). Measure rejections added beside mrb-request-filters-rejected (rollup-self dies in valid-filter; cross-type FK reaches the new arm and dies with the pinned rollup message). Two deviations, none behavioral: the :in-first placeholder-alignment probe pins $3 (two :in atoms), not :has-all; the join-context SQL assertion uses an :eq chip (A's title is B's uuid — the collision makes :eq the honest chip), while the execution test keeps the chip-plus-fk-eq pairing. Full suite green (2523 checks, 48 groups).
Plan: 01-fk-eq.org
- Slot
- 4100
- Status
- 60 Done
- Tags
- mvp, backend, frontend, model, blog
- Contributors
- Donnie