stephenmcd / mezzanine

CMS framework for Django

Home Page:http://mezzanine.jupo.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] `set_dynamic_settings` always sets the MySQL test database collation to `utf8_general_ci`

gabriellesc opened this issue ยท comments

Is there an existing issue for this?

  • I have searched the existing Issues

Current Behavior

For MySQL databases, the set_dynamic_settings util always sets the MySQL test database collation to utf8_general_ci:

db.setdefault("TEST", {})["COLLATION"] = "utf8_general_ci"

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

Anything else?

This commit exists to fix the issue, but hasn't been merged yet! 06281cf

๐ŸŽ‰ This issue has been resolved in version 5.1.1 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€

Thank you so much for fixing this so promptly, @jerivas!