From 7a74b5749c7b4f7215828d38cd9a50d2fd240a9d Mon Sep 17 00:00:00 2001 From: Thomas David Baker Date: Sat, 23 Nov 2024 08:02:01 -0800 Subject: [PATCH] Explicitly set CHARACTER SET and COLLATE everywhere Without this a comparison with our non-temporary tables can fail due to different collation if the server default differs. --- gatherling/Data/sql/migrations/80.sql | 3 +++ gatherling/Models/Format.php | 5 ++++- gatherling/Views/Components/FullMetagame.php | 20 ++++++++++---------- 3 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 gatherling/Data/sql/migrations/80.sql diff --git a/gatherling/Data/sql/migrations/80.sql b/gatherling/Data/sql/migrations/80.sql new file mode 100644 index 000000000..12918d8eb --- /dev/null +++ b/gatherling/Data/sql/migrations/80.sql @@ -0,0 +1,3 @@ +-- We must explicitly set this (which we did not at creation time) because server default may differ. +-- Our other tables have this explicitly set in schema.sql. +ALTER TABLE sessions CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; diff --git a/gatherling/Models/Format.php b/gatherling/Models/Format.php index 417bf7d9b..1c48942b8 100644 --- a/gatherling/Models/Format.php +++ b/gatherling/Models/Format.php @@ -1227,7 +1227,10 @@ public function updateLegalList(array $addCards, array $delCards): array */ private function getCurrentLegalityOfCards(array $cards): array { - $sql = "CREATE TEMPORARY TABLE input_cards (original_name VARCHAR(160))"; + $sql = ' + CREATE TEMPORARY TABLE input_cards ( + original_name VARCHAR(160) + ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci'; db()->execute($sql); $placeholders = $params = []; diff --git a/gatherling/Views/Components/FullMetagame.php b/gatherling/Views/Components/FullMetagame.php index a32ea8c40..eb2ef8188 100644 --- a/gatherling/Views/Components/FullMetagame.php +++ b/gatherling/Views/Components/FullMetagame.php @@ -46,16 +46,16 @@ public function __construct(Event $event) $players[] = $info; } $sql = ' - CREATE TEMPORARY TABLE meta - ( - player VARCHAR(40), - deckname VARCHAR(120), - archetype VARCHAR(20), - colors VARCHAR(10), - medal VARCHAR(10), - id BIGINT UNSIGNED, - srtordr TINYINT UNSIGNED DEFAULT 0 - )'; + CREATE TEMPORARY TABLE meta ( + player VARCHAR(40), + deckname VARCHAR(120), + archetype VARCHAR(20), + colors VARCHAR(10), + medal VARCHAR(10), + id BIGINT UNSIGNED, + srtordr TINYINT UNSIGNED DEFAULT 0 + ) + CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci'; db()->execute($sql); $sql = ' INSERT INTO meta