Repository navigation
[MySQL] az mysql flexible-server db create: Fix --charset and --collation being ignored - #34412
Open
nabeleon94 wants to merge 1 commit into
Open
nabeleon94 wants to merge 1 commit into
nabeleon94 wants to merge 1 commit into
Conversation
…collation` being ignored
Contributor
|
Thank you for your contribution nabeleon94! We will review the pull request and get back to you soon. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the MySQL database creation payload change.
No open issues 🎉
What changed in this PR
Fixes #34410 by ensuring MySQL flexible-server database creation sends charset and collation under properties, so Azure receives the requested values rather than silently using server defaults.
Changes:
- Uses SDK
Databasemodels for bothdb createand the default database created during server provisioning. - Removes the read-only database name from the request body while preserving it in the URL.
- Adds serialization regression tests for explicit values, command defaults, and server-created databases.
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/mysql/tests/latest/test_mysql_custom.py | Adds three regression tests using the SDK JSON encoder to verify request payloads. |
| src/azure-cli/azure/cli/command_modules/mysql/custom.py | Replaces plain dictionaries with Database models in both database creation paths. |
Review effort: Balanced
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
This branch has not been deployed
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.
🤖 PR Validation — ️✔️ All clear
Related command
az mysql flexible-server db create, and the default database created byaz mysql flexible-server createDescription
Fixes #34410.
database_create_funcand_create_databasepassedbegin_create_or_updatea plain dict withcharsetandcollationat the top level (plusname).azure-mgmt-mysqlflexibleservers1.1.0b3 serializes a plain dict as-is, and on theDatabasemodelcharset/collationare flattened properties that have to go underproperties. So the service ignored them, and the database got the server defaults (e.g.utf8mb4/utf8mb4_0900_ai_cion MySQL 8.4) while the command exited 0. That includes theutf8/utf8_general_cidefaults the command applies when neither argument is given.Both places now build
models.Database(charset=..., collation=...), the same wayfirewall_rule_create_funcbuildsmodels.FirewallRule, so the body becomes{"properties": {"charset": ..., "collation": ...}}. The read-onlynameis no longer sent; the database name is still in the URL.Testing Guide
New unit tests in
test_mysql_custom.py(MysqlFlexibleServerDatabaseCustomTest). A fake databases client serializesparameterswith the SDK's ownSdkJSONEncoder, the same call the SDK uses to build the request body:db createwith--charset utf8mb3 --collation utf8mb3_unicode_cidb createwith neither argument (defaults)_create_database(server create's default database)All three fail before the fix (body is
{"name": ..., "charset": ..., "collation": ...}) and pass after.flake8 is clean on the changed lines. Not run live against a server.
History Notes
[MySQL]
az mysql flexible-server db create: Fix--charsetand--collationbeing ignoredThis checklist is used to make sure that common guidelines for a pull request are followed.