Skip to content

Commit

Permalink
Explicitly set CHARACTER SET and COLLATE everywhere
Browse files Browse the repository at this point in the history
Without this a comparison with our non-temporary tables can fail due to
different collation if the server default differs.
  • Loading branch information
bakert committed Nov 25, 2024
1 parent 0d965ab commit 7a74b57
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
3 changes: 3 additions & 0 deletions gatherling/Data/sql/migrations/80.sql
Original file line number Diff line number Diff line change
@@ -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;
5 changes: 4 additions & 1 deletion gatherling/Models/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
20 changes: 10 additions & 10 deletions gatherling/Views/Components/FullMetagame.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7a74b57

Please sign in to comment.