You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[P0][bug] originalConfig.options is always defaultOptions — every Apply Changes emits a spurious ALTER TABLE ENGINE/CHARSET/COLLATE and silently clears table comment #378
Table Designer in alter mode loads the table's existing structure for diff baseline.
Problem
src/components/designer/TableDesigner.tsx:152-158 hardcodes originalConfig.options = { ...defaultOptions } (InnoDB / utf8mb4 / utf8mb4_general_ci) regardless of the actual table's engine/charset/collation. The diff at ddl-generator.ts:260-280 then sees original.engine !== modified.engine as a change — every Apply Changes run emits ALTER TABLE name ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; even when the user made no option change. MySQL 5.6+ accepts as a metadata-only no-op, but it triggers a table rebuild on older versions and clutters diff/migration scripts. Additionally, originalConfig.options.comment = "" is hardcoded — saving a table that has COMMENT='legacy' silently clears the comment, an actual data-loss bug.
Files
src/components/designer/TableDesigner.tsx:152-158
src-tauri/src/commands/mod.rs:279 (existing get_table_ddl command, unused by designer)
Repro
CREATE TABLE t (id INT) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='legacy'
Open Table Designer in alter mode for t
Click Apply Changes (no UI changes made)
MySQL receives ALTER TABLE t ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; — comment cleared
Expected
Apply Changes with no UI changes emits no ALTER statements. Comment is preserved.
Proposed fix
Use the existing api.getTableDdl(connectionId, database, tableName) Tauri command (commands/mod.rs:279) to fetch the actual SHOW CREATE TABLE output. Parse ENGINE=, DEFAULT CHARSET=, COLLATE=, COMMENT= from the result. Populate originalConfig.options with the parsed values. Or add a dedicated get_table_options(connection_id, database, table) -> TableOptions command in mas-core/src/schema/inspector.rs that parses server-side and returns typed TableOptions. Scope: M.
Acceptance
Loading a table with ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='legacy' and immediately clicking Apply Changes emits no ALTER TABLE … ENGINE=… statement (the diff is empty). The comment is preserved.
Activity