From fed5f3020374a7395aab3baca19edbf9d0d76c1b Mon Sep 17 00:00:00 2001 From: Andrew Klychkov Date: Tue, 16 Sep 2025 07:56:19 +0200 Subject: [PATCH] mysql_user: column_case_sensitive default is set to true (#737) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * mysql_user: column_case_sensitive default is set to true * Update plugins/modules/mysql_user.py Co-authored-by: Laurent Indermühle --------- Co-authored-by: Laurent Indermühle --- changelogs/fragments/4-column_case_sensitive.yml | 2 ++ plugins/modules/mysql_user.py | 13 ++++--------- .../tasks/test_column_case_sensitive.yml | 1 + .../test_mysql_user/tasks/test_priv_dict.yml | 2 ++ 4 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 changelogs/fragments/4-column_case_sensitive.yml diff --git a/changelogs/fragments/4-column_case_sensitive.yml b/changelogs/fragments/4-column_case_sensitive.yml new file mode 100644 index 0000000..ea75788 --- /dev/null +++ b/changelogs/fragments/4-column_case_sensitive.yml @@ -0,0 +1,2 @@ +breaking_changes: +- mysql_user - the ``column_case_sensitive`` argument's default value has been changed to ``true``. If your playbook expected the column to be automatically uppercased for your users privileges, you should set this to ``false`` explicitly (https://github.com/ansible-collections/community.mysql/issues/577). diff --git a/plugins/modules/mysql_user.py b/plugins/modules/mysql_user.py index 2a5855c..e88e2bf 100644 --- a/plugins/modules/mysql_user.py +++ b/plugins/modules/mysql_user.py @@ -182,12 +182,14 @@ options: column_case_sensitive: description: - - The default is C(false). + - The default is C(true). - When C(true), the module will not uppercase the field names in the privileges. - When C(false), the field names will be upper-cased. This is the default - This feature was introduced because MySQL 8 and above uses case sensitive fields names in privileges. + - The default changed from C(false) to C(true) in v4.0.0 type: bool + default: true version_added: '3.8.0' locked: @@ -484,7 +486,7 @@ def main(): resource_limits=dict(type='dict'), force_context=dict(type='bool', default=False), session_vars=dict(type='dict'), - column_case_sensitive=dict(type='bool', default=None), # TODO 4.0.0 add default=True + column_case_sensitive=dict(type='bool', default=True), password_expire=dict(type='str', choices=['now', 'never', 'default', 'interval'], no_log=True), password_expire_interval=dict(type='int', required_if=[('password_expire', 'interval', True)], no_log=True), locked=dict(type='bool'), @@ -567,13 +569,6 @@ def main(): module.fail_json(msg="unable to connect to database, check login_user and login_password are correct or %s has the credentials. " "Exception message: %s" % (config_file, to_native(e))) - # TODO Release 4.0.0 : Remove this test and variable assignation - if column_case_sensitive is None: - column_case_sensitive = False - module.warn("Option column_case_sensitive is not provided. " - "The default is now false, so the column's name will be uppercased. " - "The default will be changed to true in community.mysql 4.0.0.") - if not sql_log_bin: cursor.execute("SET SQL_LOG_BIN=0;") diff --git a/tests/integration/targets/test_mysql_user/tasks/test_column_case_sensitive.yml b/tests/integration/targets/test_mysql_user/tasks/test_column_case_sensitive.yml index 68e95aa..5a88ecb 100644 --- a/tests/integration/targets/test_mysql_user/tasks/test_column_case_sensitive.yml +++ b/tests/integration/targets/test_mysql_user/tasks/test_column_case_sensitive.yml @@ -33,6 +33,7 @@ password: 'msandbox' priv: 'mysql_user_column_case.t1': 'SELECT(a, B, cC, Dd)' + column_case_sensitive: false - name: Mysql_user Column case sensitive | Assert user privileges are all caps community.mysql.mysql_query: diff --git a/tests/integration/targets/test_mysql_user/tasks/test_priv_dict.yml b/tests/integration/targets/test_mysql_user/tasks/test_priv_dict.yml index f162f6b..4530b70 100644 --- a/tests/integration/targets/test_mysql_user/tasks/test_priv_dict.yml +++ b/tests/integration/targets/test_mysql_user/tasks/test_priv_dict.yml @@ -103,6 +103,7 @@ name: '{{ user_name_3 }}' priv: 'data3.test_table_issue99': 'SELECT (a, b), INSERT (a, b), UPDATE' + column_case_sensitive: false register: result - name: Priv dict | Assert that grant privs on columns is changed @@ -116,6 +117,7 @@ name: '{{ user_name_3 }}' priv: 'data3.test_table_issue99': 'SELECT (a, b), UPDATE, INSERT (b, a)' + column_case_sensitive: false register: result - name: Priv dict | Assert that grants same privs with different order is not changed