From aea98e8c5357b15da214af311e8cb74b1503f958 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Mon, 18 Feb 2013 19:06:12 +0100 Subject: [PATCH] Simplified MySQL version checking. Django used to check the version of MySQL before handling the first request, which required: - opening a connection - closing it, to avoid holding it idle until the first request. This code isn't necessary any longer since Django dropped support for some versions of MySQL, and other database backends don't implement a similar dance. For consistency and maintenability, remove it. Reverts 4423757c0c50afbe2470434778c8d5e5b4a70925. Closes #18135. --- django/db/backends/mysql/base.py | 9 --------- tests/regressiontests/backends/tests.py | 6 ------ 2 files changed, 15 deletions(-) diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index eb823083f4..754e876701 100644 --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -464,16 +464,7 @@ class DatabaseWrapper(BaseDatabaseWrapper): @cached_property def mysql_version(self): if not self.server_version: - new_connection = False - if not self._valid_connection(): - # Ensure we have a connection with the DB by using a temporary - # cursor - new_connection = True - self.cursor().close() server_info = self.connection.get_server_info() - if new_connection: - # Make sure we close the connection - self.close() m = server_version_re.match(server_info) if not m: raise Exception('Unable to determine MySQL version from version string %r' % server_info) diff --git a/tests/regressiontests/backends/tests.py b/tests/regressiontests/backends/tests.py index fbe5026e12..ed6f07691a 100644 --- a/tests/regressiontests/backends/tests.py +++ b/tests/regressiontests/backends/tests.py @@ -123,12 +123,6 @@ class MySQLTests(TestCase): else: self.assertFalse(found_reset) - @unittest.skipUnless(connection.vendor == 'mysql', - "Test valid only for MySQL") - def test_server_version_connections(self): - connection.close() - connection.mysql_version - self.assertTrue(connection.connection is None) class DateQuotingTest(TestCase):