Tested on Windows with python3.8 and MySQL8.0
--
Ticket URL: <https://code.djangoproject.com/ticket/31805>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by felixxm):
It's probably not related with running tests on Windows. Can you check a
value of the `lower_case_table_names` parameter? and share a stacktrace.
--
Ticket URL: <https://code.djangoproject.com/ticket/31805#comment:1>
* status: new => closed
* resolution: => needsinfo
--
Ticket URL: <https://code.djangoproject.com/ticket/31805#comment:2>
Comment (by Ahmad A. Hussein):
{{{
ERROR: test_alter_int_pk_to_bigautofield_pk (schema.tests.SchemaTests)
Should be able to rename an IntegerField(primary_key=True) to
----------------------------------------------------------------------
Traceback (most recent call last):
File
"c:\users\ahmad\desktop\projects\djangogsoc\django\db\backends\utils.py",
line 82, in _execute
return self.cursor.execute(sql)
File
"c:\users\ahmad\desktop\projects\djangogsoc\django\db\backends\mysql\base.py",
line 73, in execute
return self.cursor.execute(query, args)
File "C:\Users\ahmad\Envs\parallelpr\lib\site-
packages\MySQLdb\cursors.py", line 209, in execute
res = self._query(query)
File "C:\Users\ahmad\Envs\parallelpr\lib\site-
packages\MySQLdb\cursors.py", line 315, in _query
db.query(q)
File "C:\Users\ahmad\Envs\parallelpr\lib\site-
packages\MySQLdb\connections.py", line 239, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.OperationalError: (1050, "Table 'integerpk' already
exists")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\ahmad\Desktop\Projects\DjangoGSOC\tests\schema\tests.py",
line 1345, in test_alter_int_pk_to_bigautofield_pk
editor.create_model(IntegerPK)
File
"c:\users\ahmad\desktop\projects\djangogsoc\django\db\backends\base\schema.py",
line 324, in create_model
self.execute(sql, params or None)
File
"c:\users\ahmad\desktop\projects\djangogsoc\django\db\backends\base\schema.py",
line 142, in execute
cursor.execute(sql, params)
File
"c:\users\ahmad\desktop\projects\djangogsoc\django\db\backends\utils.py",
line 98, in execute
return super().execute(sql, params)
File
"c:\users\ahmad\desktop\projects\djangogsoc\django\db\backends\utils.py",
line 66, in execute
return self._execute_with_wrappers(sql, params, many=False,
executor=self._execute)
File
"c:\users\ahmad\desktop\projects\djangogsoc\django\db\backends\utils.py",
line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File
"c:\users\ahmad\desktop\projects\djangogsoc\django\db\backends\utils.py",
line 84, in _execute
return self.cursor.execute(sql, params)
File "c:\users\ahmad\desktop\projects\djangogsoc\django\db\utils.py",
line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File
"c:\users\ahmad\desktop\projects\djangogsoc\django\db\backends\utils.py",
line 82, in _execute
return self.cursor.execute(sql)
File
"c:\users\ahmad\desktop\projects\djangogsoc\django\db\backends\mysql\base.py",
line 73, in execute
return self.cursor.execute(query, args)
File "C:\Users\ahmad\Envs\parallelpr\lib\site-
packages\MySQLdb\cursors.py", line 209, in execute
res = self._query(query)
File "C:\Users\ahmad\Envs\parallelpr\lib\site-
packages\MySQLdb\cursors.py", line 315, in _query
db.query(q)
File "C:\Users\ahmad\Envs\parallelpr\lib\site-
packages\MySQLdb\connections.py", line 239, in query
_mysql.connection.query(self, query)
django.db.utils.OperationalError: (1050, "Table 'integerpk' already
exists")
----------------------------------------------------------------------
CREATE TABLE `INTEGERPK` (`i` integer NOT NULL PRIMARY KEY, `j` integer
NOT NULL UNIQUE); (params None)
(0.000) SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; args=None
(0.094) None; args=None
(0.000) SET foreign_key_checks=0; args=None
(0.016) SHOW FULL TABLES; args=None
(0.000) SET foreign_key_checks=1; args=None
======================================================================
ERROR: test_alter_int_pk_to_int_unique (schema.tests.SchemaTests)
Should be able to rename an IntegerField(primary_key=True) to
----------------------------------------------------------------------
Traceback (most recent call last):
File
"c:\users\ahmad\desktop\projects\djangogsoc\django\db\backends\utils.py",
line 82, in _execute
return self.cursor.execute(sql)
File
"c:\users\ahmad\desktop\projects\djangogsoc\django\db\backends\mysql\base.py",
line 73, in execute
return self.cursor.execute(query, args)
File "C:\Users\ahmad\Envs\parallelpr\lib\site-
packages\MySQLdb\cursors.py", line 209, in execute
res = self._query(query)
File "C:\Users\ahmad\Envs\parallelpr\lib\site-
packages\MySQLdb\cursors.py", line 315, in _query
db.query(q)
File "C:\Users\ahmad\Envs\parallelpr\lib\site-
packages\MySQLdb\connections.py", line 239, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.OperationalError: (1050, "Table 'integerpk' already
exists")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\ahmad\Desktop\Projects\DjangoGSOC\tests\schema\tests.py",
line 1383, in test_alter_int_pk_to_int_unique
editor.create_model(IntegerPK)
File
"c:\users\ahmad\desktop\projects\djangogsoc\django\db\backends\base\schema.py",
line 324, in create_model
self.execute(sql, params or None)
File
"c:\users\ahmad\desktop\projects\djangogsoc\django\db\backends\base\schema.py",
line 142, in execute
cursor.execute(sql, params)
File
"c:\users\ahmad\desktop\projects\djangogsoc\django\db\backends\utils.py",
line 98, in execute
return super().execute(sql, params)
File
"c:\users\ahmad\desktop\projects\djangogsoc\django\db\backends\utils.py",
line 66, in execute
return self._execute_with_wrappers(sql, params, many=False,
executor=self._execute)
File
"c:\users\ahmad\desktop\projects\djangogsoc\django\db\backends\utils.py",
line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File
"c:\users\ahmad\desktop\projects\djangogsoc\django\db\backends\utils.py",
line 84, in _execute
return self.cursor.execute(sql, params)
File "c:\users\ahmad\desktop\projects\djangogsoc\django\db\utils.py",
line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File
"c:\users\ahmad\desktop\projects\djangogsoc\django\db\backends\utils.py",
line 82, in _execute
return self.cursor.execute(sql)
File
"c:\users\ahmad\desktop\projects\djangogsoc\django\db\backends\mysql\base.py",
line 73, in execute
return self.cursor.execute(query, args)
File "C:\Users\ahmad\Envs\parallelpr\lib\site-
packages\MySQLdb\cursors.py", line 209, in execute
res = self._query(query)
File "C:\Users\ahmad\Envs\parallelpr\lib\site-
packages\MySQLdb\cursors.py", line 315, in _query
db.query(q)
File "C:\Users\ahmad\Envs\parallelpr\lib\site-
packages\MySQLdb\connections.py", line 239, in query
_mysql.connection.query(self, query)
django.db.utils.OperationalError: (1050, "Table 'integerpk' already
exists")
----------------------------------------------------------------------
CREATE TABLE `INTEGERPK` (`i` integer NOT NULL PRIMARY KEY, `j` integer
NOT NULL UNIQUE); (params None)
(0.000) SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; args=None
(0.000) None; args=None
(0.000) SET foreign_key_checks=0; args=None
(0.000) SHOW FULL TABLES; args=None
(0.000) SET foreign_key_checks=1; args=None
----------------------------------------------------------------------
Ran 132 tests in 1083.874s
FAILED (errors=2, skipped=18)
Destroying test database for alias 'default'...
}}}
Value for ```lower_case_table_names``` is 1 (default on Windows)
--
Ticket URL: <https://code.djangoproject.com/ticket/31805#comment:3>
Comment (by felixxm):
Do you run tests on the current master, I'm confused because we have 131
tests in `SchemaTests` and 19 tests are skipped on MySQL 8+. So it looks
that you have an extra tests (132 in logs) maybe it causes an isolation
issue. Also can you reproduce this issue when running these two tests in
isolation?
--
Ticket URL: <https://code.djangoproject.com/ticket/31805#comment:4>
Comment (by Ahmad A. Hussein):
Yes, I'm running on the latest master. The reason for the extra test is
because I'm running tests on the entire schema app, not just SchemaTests.
The extra test is from SchemaLoggerTests.
Running the tests on just SchemaTests gives the same errors.
Running the tests in complete isolation though gives a successful test
run.
--
Ticket URL: <https://code.djangoproject.com/ticket/31805#comment:5>
Comment (by felixxm):
Can you also check a storage engine and `sql_mode`? Sorry for so many
questions.
--
Ticket URL: <https://code.djangoproject.com/ticket/31805#comment:6>
Comment (by Ahmad A. Hussein):
Feel free to ask! I'm sorry I'm not much help debugging this.
Storage engine is InnoDB
sqlmode is ```sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION"``
I've ran into two new errors as well. I'm going to try to debug them and
I'll update with info once I do.
{{{
======================================================================
ERROR: aggregation.tests (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: aggregation.tests
Traceback (most recent call last):
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\base\base.py",
line 219, in ensure_connection
self.connect()
File
"c:\users\ahmad\desktop\projects\djangomain\django\utils\asyncio.py", line
26, in inner
return func(*args, **kwargs)
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\base\base.py",
line 200, in connect
self.connection = self.get_new_connection(conn_params)
File
"c:\users\ahmad\desktop\projects\djangomain\django\utils\asyncio.py", line
26, in inner
return func(*args, **kwargs)
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\mysql\base.py",
line 234, in get_new_connection
return Database.connect(**conn_params)
File "C:\Users\ahmad\Envs\djangodev\lib\site-
packages\MySQLdb\__init__.py", line 130, in Connect
return Connection(*args, **kwargs)
File "C:\Users\ahmad\Envs\djangodev\lib\site-
packages\MySQLdb\connections.py", line 185, in __init__
super().__init__(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (1049, "Unknown database 'main'")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File
"c:\users\ahmad\appdata\local\programs\python\python38\lib\unittest\loader.py",
line 436, in _find_test_path
module = self._get_module_from_name(name)
File
"c:\users\ahmad\appdata\local\programs\python\python38\lib\unittest\loader.py",
line 377, in _get_module_from_name
__import__(name)
File
"C:\Users\ahmad\Desktop\Projects\DjangoMain\tests\aggregation\tests.py",
line 21, in <module>
class AggregateTestCase(TestCase):
File
"C:\Users\ahmad\Desktop\Projects\DjangoMain\tests\aggregation\tests.py",
line 1208, in AggregateTestCase
connection.vendor == 'mysql' and 'ONLY_FULL_GROUP_BY' in
connection.sql_mode,
File "c:\users\ahmad\desktop\projects\djangomain\django\db\__init__.py",
line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File
"c:\users\ahmad\desktop\projects\djangomain\django\utils\functional.py",
line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\mysql\base.py",
line 398, in sql_mode
sql_mode = self.mysql_server_data['sql_mode']
File
"c:\users\ahmad\desktop\projects\djangomain\django\utils\functional.py",
line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\mysql\base.py",
line 359, in mysql_server_data
with self.temporary_connection() as cursor:
File
"c:\users\ahmad\appdata\local\programs\python\python38\lib\contextlib.py",
line 113, in __enter__
return next(self.gen)
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\base\base.py",
line 603, in temporary_connection
with self.cursor() as cursor:
File
"c:\users\ahmad\desktop\projects\djangomain\django\utils\asyncio.py", line
26, in inner
return func(*args, **kwargs)
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\base\base.py",
line 259, in cursor
return self._cursor()
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\base\base.py",
line 235, in _cursor
self.ensure_connection()
File
"c:\users\ahmad\desktop\projects\djangomain\django\utils\asyncio.py", line
26, in inner
return func(*args, **kwargs)
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\base\base.py",
line 219, in ensure_connection
self.connect()
File "c:\users\ahmad\desktop\projects\djangomain\django\db\utils.py",
line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\base\base.py",
line 219, in ensure_connection
self.connect()
File
"c:\users\ahmad\desktop\projects\djangomain\django\utils\asyncio.py", line
26, in inner
return func(*args, **kwargs)
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\base\base.py",
line 200, in connect
self.connection = self.get_new_connection(conn_params)
File
"c:\users\ahmad\desktop\projects\djangomain\django\utils\asyncio.py", line
26, in inner
return func(*args, **kwargs)
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\mysql\base.py",
line 234, in get_new_connection
return Database.connect(**conn_params)
File "C:\Users\ahmad\Envs\djangodev\lib\site-
packages\MySQLdb\__init__.py", line 130, in Connect
return Connection(*args, **kwargs)
File "C:\Users\ahmad\Envs\djangodev\lib\site-
packages\MySQLdb\connections.py", line 185, in __init__
super().__init__(*args, **kwargs2)
django.db.utils.OperationalError: (1049, "Unknown database 'main'")
----------------------------------------------------------------------
Ran 15 tests in 2.695s
FAILED (errors=1)
Destroying test database for alias 'default'...
(djangodev) C:\Users\ahmad\Desktop\Projects\DjangoMain\tests>runtests.py
--parallel=1 --settings=test_mysql annotations
Testing against Django installed in
'c:\users\ahmad\desktop\projects\djangomain\django'
System check identified no issues (0 silenced).
E
======================================================================
ERROR: annotations.tests (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: annotations.tests
Traceback (most recent call last):
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\base\base.py",
line 219, in ensure_connection
self.connect()
File
"c:\users\ahmad\desktop\projects\djangomain\django\utils\asyncio.py", line
26, in inner
return func(*args, **kwargs)
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\base\base.py",
line 200, in connect
self.connection = self.get_new_connection(conn_params)
File
"c:\users\ahmad\desktop\projects\djangomain\django\utils\asyncio.py", line
26, in inner
return func(*args, **kwargs)
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\mysql\base.py",
line 234, in get_new_connection
return Database.connect(**conn_params)
File "C:\Users\ahmad\Envs\djangodev\lib\site-
packages\MySQLdb\__init__.py", line 130, in Connect
return Connection(*args, **kwargs)
File "C:\Users\ahmad\Envs\djangodev\lib\site-
packages\MySQLdb\connections.py", line 185, in __init__
super().__init__(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (1049, "Unknown database 'main'")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File
"c:\users\ahmad\appdata\local\programs\python\python38\lib\unittest\loader.py",
line 436, in _find_test_path
module = self._get_module_from_name(name)
File
"c:\users\ahmad\appdata\local\programs\python\python38\lib\unittest\loader.py",
line 377, in _get_module_from_name
__import__(name)
File
"C:\Users\ahmad\Desktop\Projects\DjangoMain\tests\annotations\tests.py",
line 33, in <module>
class NonAggregateAnnotationTestCase(TestCase):
File
"C:\Users\ahmad\Desktop\Projects\DjangoMain\tests\annotations\tests.py",
line 650, in NonAggregateAnnotationTestCase
connection.vendor == 'mysql' and 'ONLY_FULL_GROUP_BY' in
connection.sql_mode,
File "c:\users\ahmad\desktop\projects\djangomain\django\db\__init__.py",
line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File
"c:\users\ahmad\desktop\projects\djangomain\django\utils\functional.py",
line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\mysql\base.py",
line 398, in sql_mode
sql_mode = self.mysql_server_data['sql_mode']
File
"c:\users\ahmad\desktop\projects\djangomain\django\utils\functional.py",
line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\mysql\base.py",
line 359, in mysql_server_data
with self.temporary_connection() as cursor:
File
"c:\users\ahmad\appdata\local\programs\python\python38\lib\contextlib.py",
line 113, in __enter__
return next(self.gen)
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\base\base.py",
line 603, in temporary_connection
with self.cursor() as cursor:
File
"c:\users\ahmad\desktop\projects\djangomain\django\utils\asyncio.py", line
26, in inner
return func(*args, **kwargs)
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\base\base.py",
line 259, in cursor
return self._cursor()
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\base\base.py",
line 235, in _cursor
self.ensure_connection()
File
"c:\users\ahmad\desktop\projects\djangomain\django\utils\asyncio.py", line
26, in inner
return func(*args, **kwargs)
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\base\base.py",
line 219, in ensure_connection
self.connect()
File "c:\users\ahmad\desktop\projects\djangomain\django\db\utils.py",
line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\base\base.py",
line 219, in ensure_connection
self.connect()
File
"c:\users\ahmad\desktop\projects\djangomain\django\utils\asyncio.py", line
26, in inner
return func(*args, **kwargs)
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\base\base.py",
line 200, in connect
self.connection = self.get_new_connection(conn_params)
File
"c:\users\ahmad\desktop\projects\djangomain\django\utils\asyncio.py", line
26, in inner
return func(*args, **kwargs)
File
"c:\users\ahmad\desktop\projects\djangomain\django\db\backends\mysql\base.py",
line 234, in get_new_connection
return Database.connect(**conn_params)
File "C:\Users\ahmad\Envs\djangodev\lib\site-
packages\MySQLdb\__init__.py", line 130, in Connect
return Connection(*args, **kwargs)
File "C:\Users\ahmad\Envs\djangodev\lib\site-
packages\MySQLdb\connections.py", line 185, in __init__
super().__init__(*args, **kwargs2)
django.db.utils.OperationalError: (1049, "Unknown database 'main'")
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31805#comment:7>
* status: closed => new
* component: Database layer (models, ORM) => Testing framework
* has_patch: 0 => 1
* resolution: needsinfo =>
* stage: Unreviewed => Accepted
Comment:
[https://github.com/django/django/pull/13221 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/31805#comment:8>
* owner: nobody => felixxm
* status: new => assigned
Comment:
Thanks Carlton for confirmation!
--
Ticket URL: <https://code.djangoproject.com/ticket/31805#comment:9>
Comment (by Carlton Gibson):
I see this on Windows 10 with MySQL 8.
{{{
...
MySQLdb._exceptions.OperationalError: (1050, "Table 'integerpk' already
exists")
...
Ran 131 tests in 42.172s
FAILED (errors=2, skipped=18)
Destroying test database for alias 'default'...
(django) PS C:\Users\carlt\src\django\tests> django-admin.exe shell
--settings=test_mysql
Python 3.7.5 (tags/v3.7.5:5c02a39a0b, Oct 15 2019, 00:11:34) [MSC v.1916
64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.db import connection
>>> connection.features.ignores_table_name_case
True
}}}
The adjustment in Mariusz´ PR fixes the failure.
--
Ticket URL: <https://code.djangoproject.com/ticket/31805#comment:10>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/31805#comment:11>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"fd53db842c35c994dbd54196dd38a908f3676b1a" fd53db8]:
{{{
#!CommitTicketReference repository=""
revision="fd53db842c35c994dbd54196dd38a908f3676b1a"
Fixed #31805 -- Fixed SchemaTests.tearDown() when table names are case-
insensitive.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31805#comment:12>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"2ff2084cfdac5c49261a091f5094feed96d0de4c" 2ff2084c]:
{{{
#!CommitTicketReference repository=""
revision="2ff2084cfdac5c49261a091f5094feed96d0de4c"
[3.1.x] Fixed #31805 -- Fixed SchemaTests.tearDown() when table names are
case-insensitive.
Backport of fd53db842c35c994dbd54196dd38a908f3676b1a from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31805#comment:13>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"dcb27ead84a91e8d38a183cfc2f7640141eb40f8" dcb27ead]:
{{{
#!CommitTicketReference repository=""
revision="dcb27ead84a91e8d38a183cfc2f7640141eb40f8"
[3.0.x] Fixed #31805 -- Fixed SchemaTests.tearDown() when table names are
case-insensitive.
Backport of fd53db842c35c994dbd54196dd38a908f3676b1a from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31805#comment:14>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"eb815938750bed7e4f8f9ec1974d60e4994a9421" eb815938]:
{{{
#!CommitTicketReference repository=""
revision="eb815938750bed7e4f8f9ec1974d60e4994a9421"
[2.2.x] Fixed #31805 -- Fixed SchemaTests.tearDown() when table names are
case-insensitive.
Backport of fd53db842c35c994dbd54196dd38a908f3676b1a from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31805#comment:15>