Skip to content

refactor(db): TableMacro becomes a thin shell over TableRules - #433

Open
rcardin wants to merge 7 commits into
devfrom
refactor/table-macro-thin-shell
Open

rcardin wants to merge 7 commits into
devfrom
refactor/table-macro-thin-shell

Conversation

@rcardin

@rcardin rcardin commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Why

derives Table is a macro. Its body runs in the compiler, so no test run executes it. Stryker4s gave every mutant of TableMacro the status NoCoverage, and a change to a table name, a column name or the text of a compile error could not be caught by a mutant.

What

TableMacro becomes a thin shell over a new object, TableRules.

  • TableRules holds the decisions that need no compiler: the table name, the column names, the place of the key (isKey), and the text of each compile error. It is a plain object, private to eezo.
  • TableMacro keeps only what needs Quotes. Its body is split into methods of complexity 2 or lower.
  • The derived Table and the compile errors are the same as before. No public API changes.

How to review

  1. Read TableRules.scala (41 lines) first. It is the full list of decisions.
  2. Read TableMacro.scala and check that each remaining method only talks to the compiler.
  3. Read the suites:
    • TableRulesSuite calls TableRules directly.
    • CapabilitySuite pins four refused derivations by their only compile error and its whole text: a model with no fields; an id of type Id[Untabled]; and the two cases where a key refusal and a missing mapping apply to the same model, where the key refusal wins.
    • TableDerivationSuite asserts that a column that is not a Ref has no FK target.
    • isKey refuses ID and Id, pinned as it is today. A field of type java.net.URI is refused with the whole missing mapping text.

The commits are small and can be read one at a time.

How it was tested

bin/gate is green on this branch, rebased on dev at 0444b6e, with JDK 25. The db module has 383 tests, all green.

🤖 Generated with Claude Code

rcardin and others added 7 commits November 25, 2026 08:29
The decisions of derives Table that need no compiler move to TableRules, a
plain object that TableRulesSuite calls directly: the table and column names,
the place of the key, and the text of each compile error. No test run
executes a macro body, so before this change Stryker4s gave every mutant of
TableMacro the status NoCoverage.

TableMacro keeps only what needs Quotes, split into methods of complexity 2
or lower. The derived Table and the compile errors are the same.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Four derivations in CapabilitySuite, each asserting the only compile error
and its full text: a model with no fields; an id of type Id[Untabled], which
a check on the outer type alone would let through; and the two cases where a
key refusal and a missing mapping apply to the same model, where the key
refusal wins.
The shell picks the FK target of a column with map and getOrElse. The Some
outcome was asserted on a derived Table already; this asserts the None one,
on every column of Author.
The Expansion scaladoc named the fields as the order of every check, but the
key type and the missing mapping are checked while table runs. The claim that
no test run executes a macro body was not exact: the compiler runs it while it
compiles the test sources, and a suite sees its trees and its compile errors.
isKey now says it is a test on the name.
…derivation

isKey refuses ID and Id, pinned as it is today. A field of type java.net.URI
is refused with the whole noMapping text, through derives Table, which also
shows that the two refusal order tests have a second refusal to lose to. The
TableRulesSuite scaladoc no longer says no test run sees the macro.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant