Reject :sortable t on :target fields
:sortable t on a :target (FK) field compiles today, then 500s at click time. compile-field-stage-2 rewrites the field's :source :column-name to the joined table's display column (e.g. users.user_name), but base Phase A SQL has no join, so Postgres raises 42P01 "missing FROM-clause entry". Observed live on Model Bank :models :user (Owner header). The existing guard passes it because compile-field force-sets :column t on any :target field.
Fix: compile-time reject, uniformly (base types and rollups — the memorable rule is ":target is never sortable"). compile-field already binds has-target beside the :searchable check that rejects FK fields; add the same shape inside the :sortable when, report-e matching its neighbors. Also drop :sortable t from :models :user in models/modelbank.lisp (the only current instance), update the :sortable row in docs/model-reference.md, and add a (signals error) compile test to tests/sortable-tests.lisp (test-suite edit permission granted <span class="timestamp-wrapper"><span class="timestamp">[2026-10-19 Mon]</span></span>; see the plan header).
Plan: target-non-sortable-plan.org. Superseded by "Sort by :target field display column" below when that lands.
Implemented per the plan:
lisp/model.lisp:compile-fieldfinallyblock — uniformhas-targetrejection at the top of the:sortablewhen(report-e"compile-field", wording mirroring the:searchableFK rejection), ahead of the unchanged rollup/base branches. Base-case mechanism (stage-2 rewrite → 42P01) documented in the comment; no rollup claim made.models/modelbank.lisp::sortable tdropped from:models:user(Owner header no longer clickable).models/books.lisp(plan deviation, found by the widget suite's all-models compile sweep)::my-ratings:bookalso declared:sortable ton a:target :booksfield — not in the plan's impact audit; dropped the same way.docs/model-reference.md: one clause appended to the:sortablefield-key row (compile error on:targetFK fields, all types; points at "Sort by:targetfield display column").tests/sortable-tests.lisp: three tests — base-type rejection (signals erroron inlinecompile-model), positive control (same model minus:sortable tcompiles), rollup pass-through rejection.- Verification order followed: guard in first,
(set-model "modelbank")failed naming:userof:models, then modelbank fixed and recompiled;(be-list :models "admin" :sort '(:name :asc))works;fe-fieldsno longer marks Owner sortable. - Full suite via
scripts/data-ui tests: 2067 checks, 38 groups, all passed.
- Slot
- 2600
- Status
- 60 Done
- Tags
- compiler, bug
- Contributors
- Donnie