Skip to content

Commit 8f0ff80

Browse files
committed
fix: resolve team names through tournament_teams.team_id fallback
When teams join a tournament with an existing team, tournament_teams.name is NULL. The get_team_name function now falls back to the linked teams.name via tournament_teams.team_id instead of showing the captain's name.
1 parent 2258138 commit 8f0ff80

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

hasura/functions/match/get_team_name.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ BEGIN
2727
RETURN _team_name;
2828
END IF;
2929

30-
SELECT tt.name
30+
SELECT COALESCE(tt.name, t2.name)
3131
INTO _team_name
3232
FROM matches m
3333
JOIN tournament_brackets tb ON tb.match_id = m.id
@@ -41,6 +41,7 @@ BEGIN
4141
match_lineup.id = m.lineup_2_id
4242
AND tt.id = tb.tournament_team_id_2
4343
)
44+
LEFT JOIN teams t2 ON t2.id = tt.team_id
4445
WHERE m.id = (
4546
SELECT match_id
4647
FROM match_lineups

0 commit comments

Comments
 (0)