Skip to content

fix(designer): keep column modifiers through an edit instead of dropping them - #547

Merged
EVWorth merged 1 commit into
mainfrom
fix/designer-column-modifiers
Sep 5, 2026
Merged

EVWorth merged 1 commit into
mainfrom
fix/designer-column-modifiers

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Closes #377.

What was wrong

A column was loaded by taking the leading word of COLUMN_TYPE as the type and whatever was in brackets as the length. Everything else was discarded. int(10) unsigned zerofill came back as INT and "10", so editing that column — its name, its comment, anything — emitted:

MODIFY COLUMN `big` INT(10) NOT NULL

and the column stopped being unsigned.

Confirmed against MySQL 8, both ways it can go:

sql_mode What happens
strict (the default) The ALTER fails with ERROR 1264 when a row holds more than 2^31-1. Where no row does, it succeeds — leaving a signed column that rejects those values from then on.
non-strict Existing data is clamped, silently. 4000000000 became 2147483647.

CHARACTER SET and COLLATE went the same way, falling back to the table default, and ON UPDATE CURRENT_TIMESTAMP was dropped because it lives in EXTRA rather than in the type.

The fix

Charset and collation aren't in COLUMN_TYPE at all, so get_columns now also selects CHARACTER_SET_NAME and COLLATION_NAME; ColumnInfo carries both as Option, since they're only set when a column overrides the table's.

parseColumnType reads the rest out of COLUMN_TYPE, and parseOnUpdate takes the ON UPDATE half of EXTRA — only that half, since the DEFAULT_GENERATED preceding it describes the DEFAULT and must not be re-emitted.

buildColumnDef puts each where MySQL requires it: UNSIGNED/ZEROFILL as part of the type, CHARACTER SET/COLLATE between the type and NOT NULL, ON UPDATE after DEFAULT. isColumnChanged compares them too, so asking to drop UNSIGNED is a change rather than a no-op.

No new controls. The designer still can't set these deliberately; it just stops destroying them. Adding the controls is a feature, and the type-list gaps behind the VARCHAR fallback are #382.

Verified on both servers

MySQL 8 and MariaDB 11 both round-trip the emitted statements with the column reported back unchanged and the value still stored:

big  int(10) unsigned zerofill
s    varchar(20)                 utf8mb4_bin
ts   timestamp                   on update CURRENT_TIMESTAMP
big = 4000000000

Ten unit tests on the parsers (including an ENUM whose members contain a bracket, and one whose members are literally 'unsigned','zerofill'), five on the generator, one integration test per server. Four of the five generator tests fail against the previous version; the fifth asserts an untouched column still emits nothing.

46 integration tests against live servers, 1742 unit + 298 browser, clippy/tsc/dprint/eslint clean.

One correction to the issue

Its repro says to click Apply Changes without editing anything. That emits no statement at all — the diff only produces a MODIFY for a column that differs — so the damage needs an edit to the column in question. The bug is real and serious; that particular path to it isn't. Same pattern as #378, where the stated repro also didn't hold.

🤖 Generated with Claude Code

…ing them

Closes #377.

A column was loaded by taking the leading word of COLUMN_TYPE as the type
and whatever was in brackets as the length. Everything else was discarded.
`int(10) unsigned zerofill` came back as INT and "10", so editing that
column — its name, its comment, anything — emitted

    MODIFY COLUMN `big` INT(10) NOT NULL

and the column stopped being unsigned. Confirmed against MySQL 8, both ways
it can go:

  - strict mode, the default: the ALTER fails outright with ERROR 1264 when
    a row holds more than 2^31-1, and where no row does it succeeds and
    leaves a signed column that rejects those values from then on
  - strict mode off: existing data is clamped. 4000000000 became
    2147483647, with no error

CHARACTER SET and COLLATE went the same way, falling back to the table
default, and `ON UPDATE CURRENT_TIMESTAMP` was dropped because it lives in
EXTRA rather than in the type.

Charset and collation are not in COLUMN_TYPE at all, so get_columns now
selects CHARACTER_SET_NAME and COLLATION_NAME as well; ColumnInfo carries
both as Option, since they are only set when a column overrides the table.
parseColumnType reads the rest out of COLUMN_TYPE and parseOnUpdate takes
the ON UPDATE half of EXTRA — only that half, since the DEFAULT_GENERATED
that precedes it describes the DEFAULT and must not be re-emitted.

DesignerColumn carries the five as optional fields and buildColumnDef puts
each where MySQL requires it: UNSIGNED and ZEROFILL as part of the type,
CHARACTER SET and COLLATE between the type and NOT NULL, ON UPDATE after
DEFAULT. isColumnChanged compares them too, so asking to drop UNSIGNED is a
change rather than a no-op.

No new controls. The designer still cannot set these deliberately; it just
stops destroying them. Adding the controls is a feature, and the type-list
gaps behind the VARCHAR fallback are #382.

Verified on both servers, which round-trip the emitted statements with the
column reported back unchanged and the 4000000000 still stored:

    big  int(10) unsigned zerofill
    s    varchar(20)                utf8mb4_bin
    ts   timestamp                  on update CURRENT_TIMESTAMP

Ten unit tests on the parsers, five on the generator, and one integration
test per server. Four of the five generator tests fail against the previous
version; the fifth asserts an untouched column still emits nothing.

The issue's repro says to click Apply Changes without editing anything.
That emits no statement at all — the diff only produces MODIFY for a column
that differs — so the damage needs an edit to the column in question. The
bug is real; that path to it is not.

Co-Authored-By: Claude Opus 5 <[email protected]>
@EVWorth
EVWorth merged commit e867dc6 into main Sep 5, 2026
10 checks passed
@EVWorth
EVWorth deleted the fix/designer-column-modifiers branch September 5, 2026 21:51
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