Repository navigation
fix(designer): load a table's real options instead of assuming the defaults - #546
Merged
Merged
Conversation
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 fix
Both now come from the table's own DDL, through the existing
get_table_ddlcommand — no new backend command, no bindings regen.parseTableOptionsreads the trailing clause, which MySQL 8 and MariaDB 11 emit identically (confirmed against both):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
uca1400collations, 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:
ALTER TABLE … ENGINE=…"-- No changes detected.COMMENT='legacy'silently clears the comment""", so noCOMMENTclause 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