From 7099b1946da1979c7612171cc16eb71b9bde8dfb Mon Sep 17 00:00:00 2001 From: Ariel Rin Date: Mon, 15 Jul 2024 12:18:47 +0000 Subject: [PATCH] More Detail on the SQL charset check --- allianceauth/checks.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/allianceauth/checks.py b/allianceauth/checks.py index 82ee858c..057efd36 100644 --- a/allianceauth/checks.py +++ b/allianceauth/checks.py @@ -140,11 +140,19 @@ def sql_settings(app_configs, **kwargs) -> List[CheckMessage]: errors: List[CheckMessage] = [] for connection in db.connections.all(): if connection.vendor == "mysql": - if connection.settings_dict["OPTIONS"]["charset"] != "utf8mb4": - errors.append(Error("SQL Charset is not set correctly", hint="https://gitlab.com/allianceauth/allianceauth/-/commit/89be2456fb2d741b86417e889da9b6129525bec8", id="allianceauth.checks.B001")) + try: + if connection.settings_dict["OPTIONS"]["charset"] != "utf8mb4": + errors.append(Error(f"SQL Charset is not set to utf8mb4 DB:{connection.alias}", hint="https://gitlab.com/allianceauth/allianceauth/-/commit/89be2456fb2d741b86417e889da9b6129525bec8", id="allianceauth.checks.B001")) + except KeyError: + errors.append(Error(f"SQL Charset is not set to utf8mb4 DB:{connection.alias}", hint="https://gitlab.com/allianceauth/allianceauth/-/commit/89be2456fb2d741b86417e889da9b6129525bec8", id="allianceauth.checks.B001")) + # This hasn't actually been set on AA yet - # if connection.settings_dict["OPTIONS"]["charset"] != "utf8mb4_unicode_ci": - # errors.append(Error("SQL Collation is not set correctly", hint="", id="allianceauth.checks.B002")) + # try: + # if connection.settings_dict["OPTIONS"]["collation"] != "utf8mb4_unicode_ci": + # errors.append(Error(f"SQL Collation is not set to utf8mb4_unicode_ci DB:{connection.alias}", hint="https://gitlab.com/allianceauth/allianceauth/-/commit/89be2456fb2d741b86417e889da9b6129525bec8", id="allianceauth.checks.B001")) + # except KeyError: + # errors.append(Error(f"SQL Collation is not set to utf8mb4_unicode_ci DB:{connection.alias}", hint="https://gitlab.com/allianceauth/allianceauth/-/commit/89be2456fb2d741b86417e889da9b6129525bec8", id="allianceauth.checks.B001")) + # if connection.vendor == "sqlite": return errors