Skip to content

fix(designer): load a table's real options instead of assuming the defaults - #546

Merged
EVWorth merged 1 commit into
mainfrom
fix/designer-table-options
Sep 5, 2026
Merged

EVWorth merged 1 commit into
mainfrom
fix/designer-table-options

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Closes #378.

What was wrong

Alter mode initialised both the Options form and the diff baseline from the same hardcoded defaults — InnoDB, utf8mb4, utf8mb4_general_ci, no comment — whatever the table actually was.

Two consequences:

  • The Options tab misreported every table. A MyISAM table on utf8mb3 with a comment opened claiming to be InnoDB on utf8mb4 with none.
  • A change towards a default was silently discarded. Selecting InnoDB for a MyISAM table compared the new value against a baseline that already said InnoDB, so the diff came back empty and the user was told "No changes detected". The request vanished with no error.

The fix

Both now come from the table's own DDL, through the existing get_table_ddl command — no new backend command, no bindings regen. parseTableOptions reads the trailing clause, which MySQL 8 and MariaDB 11 emit identically (confirmed against both):

) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin COMMENT='legacy o''brien'

Note the quoting — a single quote inside the comment is doubled, not backslashed, so unescaping is the inverse of that rather than of the string rules used elsewhere in the codebase. The clause is located from the end of the DDL, since a column comment can contain anything, including a newline followed by a bracket. There's a test for exactly that.

Second problem, found by fixing the first: the charset and collation selects are fixed lists, and a select whose value matches no option renders blank. A table on utf8mb3, or on one of MariaDB's uca1400 collations, would have loaded correctly and then displayed as nothing. The current value is now prepended to the list when it isn't already there.

The issue's account is wrong, in an interesting direction

I checked both claims before changing anything, and neither reproduces:

Claim Reality
"every Apply Changes emits a spurious ALTER TABLE … ENGINE=…" It does not. Both sides of the diff held the same defaults, so an untouched table produced -- No changes detected.
"saving a table with COMMENT='legacy' silently clears the comment" It does not. Both sides held "", so no COMMENT clause was emitted and the existing comment was left alone.

What actually happened is close to the inverse: nothing spurious was emitted, and changes the user did ask for were dropped. Same hardcoded baseline, harm in the other direction. Worth knowing because the acceptance criteria as written would have passed against the broken code.

Tests

Six unit tests on the parser (real captured DDL from both servers, the doubled-quote comment, the tricky column comment, the no-clause fallback), three on the component. The two component tests asserting new behaviour fail against the previous version — verified by stashing the component.

1727 unit + 298 browser green, tsc/dprint/eslint clean.

🤖 Generated with Claude Code

…faults

Closes #378.

Alter mode initialised both the Options form and the diff baseline from the
same hardcoded defaults — InnoDB, utf8mb4, utf8mb4_general_ci, no comment —
whatever the table actually was. Two consequences.

The Options tab misreported every table. A MyISAM table on utf8mb3 with a
comment opened claiming to be InnoDB on utf8mb4 with none.

The damaging one: a change *towards* a default was silently discarded.
Selecting InnoDB for a MyISAM table compared the new value against a
baseline that already said InnoDB, so the diff came back empty and the user
was told "No changes detected". The request vanished with no error.

Both now come from the table's own DDL, via the existing get_table_ddl
command. parseTableOptions reads the trailing clause, which MySQL 8 and
MariaDB 11 emit identically — confirmed against both:

    ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3
      COLLATE=utf8mb3_bin COMMENT='legacy o''brien'

Note the quoting: a single quote inside the comment is doubled, not
backslashed, so unescaping is the inverse of that and not of the string
rules used elsewhere. The clause is located from the end of the DDL, since
a column comment can contain anything, including a newline and a bracket.

Loading real values exposed a second problem: the charset and collation
selects are fixed lists, and a select whose value matches no option renders
blank. A table on utf8mb3, or on one of MariaDB's uca1400 collations, would
have loaded correctly and then displayed as nothing. The current value is
prepended to the list when it is not already there.

## On the issue's account

Two of its claims do not reproduce, and the real defect is close to their
inverse. Checked before changing anything:

- "every Apply Changes emits a spurious ALTER TABLE ENGINE/CHARSET/COLLATE"
  — it does not. Both sides of the diff held the same defaults, so an
  untouched table produced "-- No changes detected".
- "saving a table that has COMMENT='legacy' silently clears the comment" —
  it does not. Both sides held "", so no COMMENT clause was emitted at all
  and the existing comment was left alone.

What actually happened is the opposite: nothing spurious was emitted, and
changes the user did ask for were dropped. Same hardcoded baseline, harm in
the other direction.

Six unit tests on the parser, three on the component. The two component
tests asserting new behaviour fail against the previous version.

Co-Authored-By: Claude Opus 5 <[email protected]>
@EVWorth
EVWorth merged commit ce098fb into main Sep 5, 2026
10 checks passed
@EVWorth
EVWorth deleted the fix/designer-table-options branch September 5, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant