Skip to content

A column an ALTER TABLE adds is placed on its own line, not on the ALTER's - #20

Open
avison9 wants to merge 2 commits into
mainfrom
feat/alter-column-lines
Open

avison9 wants to merge 2 commits into
mainfrom
feat/alter-column-lines

Conversation

@avison9

@avison9 avison9 commented Sep 26, 2026

Copy link
Copy Markdown
Owner

What it changes

In a multi-line ALTER TABLE, every added column was positioned at the statement's first line, so a migration adding three columns reported all three at the same line (RefuseRadar #963: three reports columns, all at :6). Each added column now takes its own line, in both the Postgres and the MySQL reader. This was item 6 on the roadmap.

The readers parse actions with their whitespace folded, so an action cannot be found in the file verbatim. Each added column's name is searched for in the statement text instead (ddl.NameLine): as a whole word, case-insensitively, starting after the table's name and after the previous action. When it cannot be found, the statement's line stays, as before.

It is also the prerequisite for the next PR, a cdclint:ignore marker on the line that adds a column, which needs that column's finding to point at that line.

Corpus changes (line numbers only, read line by line)

entry before after
diff-connector-captures-one-of-two :5 :7, where movement_cleared_by is added
diff-connector-touched-other-table three findings at :6 :7 movement_cleared_at, :8 movement_cleared_by, :9 movement_clear_reason

The second entry's findings also change order: sharing one line they were sorted by message; on their own lines they sort in file order. Every message is word for word unchanged.

Verified

  • Unit tests in both readers: columns on their own lines across a comment between actions, a one-line ALTER, MySQL's ADD (a, b) list and AFTER, and names that contain the table's name (reports_note in reports), which only a whole-word search places right.
  • gofmt -l . clean, go vet, go test ./... pass. RefuseRadar: 0 error(s), 0 warning(s), 161 info.

Merging

Stacked on #19 (its commit shows in this diff until #19 merges). Merge #19, then this.

…what it left out

A repository that has read its inventory of uncaptured columns does not
want it on every run: RefuseRadar prints 161 source-column-not-captured
lines and set 2026-10-21 to decide whether they stay. --disable RULE
(comma-separated or repeated) drops a rule's findings from the output
and from the exit code.

A filter must not make a run look cleaner than it was, so the text
output ends with what was left out ("not shown (--disable):
source-column-not-captured 161"), a run whose every finding was hidden
says "ok: nothing to report outside the disabled rules" rather than
that the files agree, and --format json keeps its array shape and puts
the same note on stderr. An unknown rule name is an error listing the
rules, not a filter that silently hides nothing; engine.Rules is that
list, and the corpus test fails if any finding's rule is missing from
it.

Disabling schema-before-connector skips the base altogether, as if
--base were not given. Filtering its findings afterwards would also
lose the columns it raised, because source-column-not-captured leaves
raised columns out of its inventory, so they would appear nowhere.

The action gains a disable input. run() now takes its output streams,
so the tests drive the real command line: hiding a rule, a disabled
error no longer failing the run, commas and repeats, an unknown name,
the base skipped, and JSON's stderr note.
…TER's

In a multi-line ALTER TABLE every added column was positioned at the
statement's first line, so three columns added by one migration were
reported at the same line (RefuseRadar #963's three reports columns all
at :6). The readers parse actions with their whitespace folded, so an
action cannot be found in the file verbatim; each added column's name is
now searched for in the statement text, as a whole word, after the
table's name and after the previous action, and the column takes that
line. When the name cannot be found the statement's line stays, as
before.

This is also what lets a marker on the line that adds a column refer to
that column's finding.

Two corpus entries change, line numbers only: diff-connector-captures-
one-of-two (:5 to :7, movement_cleared_by's own line) and
diff-connector-touched-other-table (three findings at :6 become :7, :8,
:9, now in file order instead of message order). Every message is
unchanged.
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