Skip to content

Commit

Permalink
Merge pull request #855 from PennyDreadfulMTG/deck-nullables
Browse files Browse the repository at this point in the history
Various improvements
  • Loading branch information
bakert authored Nov 25, 2024
2 parents afbdcc9 + e8b373f commit bea7a68
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 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
3 changes: 3 additions & 0 deletions gatherling/Models/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ public static function sanitizeUsername(string $playerName): string

public static function createByName(string $playername): self
{
if (strlen($playername) > 40) {
throw new ValidationException('Username too long (must be less than 40 characters)');
}
$sql = 'INSERT INTO players (name) VALUES (:player_name)';
$params = ['player_name' => $playername];
db()->execute($sql, $params);
Expand Down
2 changes: 1 addition & 1 deletion gatherling/Models/Series.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Series
public array $bannedplayers;
public ?string $mtgo_room;

public ?string $this_season_format;
public ?string $this_season_format = null;
public ?string $this_season_master_link = null;
public int $this_season_season;

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 bea7a68

Please sign in to comment.