Context
Table Designer loads existing table structure in alter mode via getColumns/getIndexes, then saves back via generateAlterTable.
Problem
src/components/designer/TableDesigner.tsx:920-940 (extractBaseType, extractLength) parses the inspector's column_type string. For INT(11) UNSIGNED ZEROFILL, it captures baseType: "INT", length: "11" — UNSIGNED and ZEROFILL are dropped. buildColumnDef (ddl-generator.ts:48-72) emits INT(11) NOT NULL AUTO_INCREMENT DEFAULT … COMMENT … but never UNSIGNED ZEROFILL. On save, MySQL silently narrows the column to signed INT — values > 2^31-1 fail with ERROR 1264 (22003): Out of range value. Similarly, VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin loses both modifiers → MySQL falls back to table default (may differ). DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP — the extra field "DEFAULT_GENERATED on update CURRENT_TIMESTAMP" is dropped (only auto_increment check on line 920-940 catches one EXTRA pattern).
Files
- src/components/designer/TableDesigner.tsx:920-940 (extractBaseType, extractLength)
- src/lib/ddl-generator.ts:48-72 (buildColumnDef)
- src/types/index.ts:173-182 (ColumnInfo interface)
- src-tauri/crates/mas-core/src/schema/inspector.rs (get_columns)
Repro
- CREATE TABLE t (id INT(11) UNSIGNED ZEROFILL NOT NULL)
- Open Table Designer in alter mode for t
- Click Apply Changes
SHOW CREATE TABLE t shows int(11) NOT NULL — UNSIGNED ZEROFILL lost
Expected
Round-trip preserves all column modifiers.
Proposed fix
(1) Extend ColumnInfo in src/types/index.ts and inspector.rs:get_columns to include column_attributes: String[] (split from COLUMN_TYPE on whitespace after the length parens — e.g. ["UNSIGNED", "ZEROFILL"]). Add extra_on_update: Option from EXTRA column. (2) Extend DesignerColumn (ddl-generator.ts:5-14) with unsigned, zerofill, charset, collate, onUpdate. (3) extractBaseType/extractLength parse the suffix. (4) buildColumnDef appends UNSIGNED/ZEROFILL after the type and CHARACTER SET/COLLATE after NOT NULL. (5) Add a separate ALTER TABLE … MODIFY COLUMN x TIMESTAMP … ON UPDATE CURRENT_TIMESTAMP emission for timestamp columns. Scope: M.
Acceptance
INT(11) UNSIGNED ZEROFILL NOT NULL round-trips: load → save → SHOW CREATE TABLE shows UNSIGNED ZEROFILL preserved. VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin round-trips with charset/collate. created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP round-trips with ON UPDATE preserved.
Needs human verify
yes
Doc drift
no
Context
Table Designer loads existing table structure in alter mode via getColumns/getIndexes, then saves back via generateAlterTable.
Problem
src/components/designer/TableDesigner.tsx:920-940(extractBaseType,extractLength) parses the inspector's column_type string. ForINT(11) UNSIGNED ZEROFILL, it captures baseType: "INT", length: "11" — UNSIGNED and ZEROFILL are dropped.buildColumnDef(ddl-generator.ts:48-72) emitsINT(11) NOT NULL AUTO_INCREMENT DEFAULT … COMMENT …but neverUNSIGNED ZEROFILL. On save, MySQL silently narrows the column to signed INT — values > 2^31-1 fail withERROR 1264 (22003): Out of range value. Similarly,VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_binloses both modifiers → MySQL falls back to table default (may differ).DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP— theextrafield "DEFAULT_GENERATED on update CURRENT_TIMESTAMP" is dropped (only auto_increment check on line 920-940 catches one EXTRA pattern).Files
Repro
SHOW CREATE TABLE tshowsint(11) NOT NULL— UNSIGNED ZEROFILL lostExpected
Round-trip preserves all column modifiers.
Proposed fix
(1) Extend ColumnInfo in src/types/index.ts and inspector.rs:get_columns to include column_attributes: String[] (split from COLUMN_TYPE on whitespace after the length parens — e.g. ["UNSIGNED", "ZEROFILL"]). Add extra_on_update: Option from EXTRA column. (2) Extend DesignerColumn (ddl-generator.ts:5-14) with unsigned, zerofill, charset, collate, onUpdate. (3) extractBaseType/extractLength parse the suffix. (4) buildColumnDef appends UNSIGNED/ZEROFILL after the type and CHARACTER SET/COLLATE after NOT NULL. (5) Add a separate ALTER TABLE … MODIFY COLUMN x TIMESTAMP … ON UPDATE CURRENT_TIMESTAMP emission for timestamp columns. Scope: M.
Acceptance
INT(11) UNSIGNED ZEROFILL NOT NULL round-trips: load → save → SHOW CREATE TABLE shows UNSIGNED ZEROFILL preserved. VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin round-trips with charset/collate. created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP round-trips with ON UPDATE preserved.
Needs human verify
yes
Doc drift
no