Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #30636 -- Fixed options ordering when cloning test database on MySQL. #11567

Merged
merged 1 commit into from Jul 16, 2019

Conversation

fallen
Copy link
Contributor

@fallen fallen commented Jul 14, 2019

No description provided.

Copy link
Member

@felixxm felixxm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fallen Thanks for this patch 👍 Can you add test to the backends/mysql/test_creation.py? It can be tricky, e.g.

def test_clone_test_db_options_ordering(self):
    creation = DatabaseCreation(connection)
    try:
        saved_settings = connection.settings_dict
        connection.settings_dict = {
            ...
        }
        with mock.patch.object(subprocess, 'Popen') as mocked_popen:
            creation._clone_db('source_db', 'target_db')
            mocked_popen.assert_has_calls([
                mock.call(
                    ['mysqldump', '--defaults-file=my.cnf', '--routines', '--events', 'source_db'],
                    stdout=subprocess.PIPE,
                ),
            ])
    finally:
       connection.settings_dict = saved_settings

django/db/backends/mysql/creation.py Outdated Show resolved Hide resolved
@felixxm felixxm self-assigned this Jul 15, 2019
@fallen
Copy link
Contributor Author

fallen commented Jul 15, 2019

For the test, I would need time to write it as I am not used to Mock stuff at all, and this use-case seems rather advanced.
If you want to write the test yourself please feel free to do it.
If not, I'll do it but it will take a bit of time :)

@felixxm
Copy link
Member

felixxm commented Jul 15, 2019

@fallen I've provided test in comment. I can add it to this patch, np.

@felixxm felixxm changed the title Fixed #30636 -- correctly handle argument order for mysqldump Fixed #30636 -- Fixed options ordering when cloning test database on MySQL. Jul 16, 2019
…MySQL.

--defaults-file must be given before other options.
@felixxm
Copy link
Member

felixxm commented Jul 16, 2019

@fallen Thanks! I added test.

@felixxm felixxm merged commit e47b829 into django:master Jul 16, 2019
@fallen
Copy link
Contributor Author

fallen commented Jul 16, 2019

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants