For MySQL databases, the set_dynamic_settings util always sets the MySQL test database collation to utf8_general_ci: https://github.com/stephenmcd/mezzanine/blob/001a16b052578ba8b29e847a1949dcdee5b400f6/mezzanine/utils/conf.py#L250
Unfortunately, the utf8_general_ci collation is only compatible with the utf8 charset, which means that it is not possible to run tests with a test database that uses a different charset, eg. utf8mb4_* charsets. When attempting to do so, we see an error like:
(1253, "COLLATION 'utf8_general_ci' is not valid for CHARACTER SET 'utf8mb4'")
Expected Behavior
We should be able to set the test database collation in the app settings and have the set_dynamic_settings util respect that, rather than overriding it.
Steps To Reproduce
Here is a repo containing a sample Django app with mezzanine, that demonstrates the issue: https://github.com/bevy/mezzanine-fix-demo
Following the steps in the repo and running tox, you can see that the error occurs with mezzanine 5.1.0 and both Django 2.2 and 3.2 (but does not occur when using a version of mezzanine that defers to the test database collation in the app settings).
Environment
- Operating System: macOS Big Sur/Ubuntu 18.04
- Python version: 3.7
- Django version: 2.2/3.2
- Database engine and version: MySQL 5.7
- Mezzanine version: 5.1.0
Is there an existing issue for this?
Current Behavior
For MySQL databases, the
set_dynamic_settings
util always sets the MySQL test database collation toutf8_general_ci
: https://github.com/stephenmcd/mezzanine/blob/001a16b052578ba8b29e847a1949dcdee5b400f6/mezzanine/utils/conf.py#L250 Unfortunately, theutf8_general_ci
collation is only compatible with theutf8
charset, which means that it is not possible to run tests with a test database that uses a different charset, eg.utf8mb4_*
charsets. When attempting to do so, we see an error like:Expected Behavior
We should be able to set the test database collation in the app settings and have the
set_dynamic_settings
util respect that, rather than overriding it.Steps To Reproduce
Here is a repo containing a sample Django app with mezzanine, that demonstrates the issue: https://github.com/bevy/mezzanine-fix-demo Following the steps in the repo and running
tox
, you can see that the error occurs with mezzanine 5.1.0 and both Django 2.2 and 3.2 (but does not occur when using a version of mezzanine that defers to the test database collation in the app settings).Environment
Anything else?
This commit exists to fix the issue, but hasn't been merged yet! https://github.com/stephenmcd/mezzanine/commit/06281cf9c030e17f342d2eed1c3b267728c07870