Skip to content

[P0][bug] originalConfig.options is always defaultOptions — every Apply Changes emits a spurious ALTER TABLE ENGINE/CHARSET/COLLATE and silently clears table comment #378

Closed

Description

@EVWorth

Context

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

  1. CREATE TABLE t (id INT) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='legacy'
  2. Open Table Designer in alter mode for t
  3. Click Apply Changes (no UI changes made)
  4. 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.

Needs human verify

yes

Doc drift

no

Activity

  1. added
    audit
    severity/p0
    kind/bug
    area/designer
    on Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/designerauditkind/bugseverity/p0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions