unionAll nullable typing error

I have something like this
  const blackPlayerOneEloChanges = db
    .select({
      player_id: matches.blackPlayerOne,
      elo_change: matches.blackEloChange,
    })
    .from(matches)
    .where(isNotNull(matches.blackPlayerOne));
  const blackPlayerTwoEloChanges = db
    .select({
      player_id: matches.blackPlayerTwo,
      elo_change: matches.blackEloChange,
    })
    .from(matches)
    .where(isNotNull(matches.blackPlayerTwo));;

then I do a unionAll(blackPlayerOneEloChanges, blackPlayerTwoEloChanges and get the following error, because blackPlayerTwo is nullable, it's optional, the question is if there is anyway I can override the type of playerid in the blackPlayerTwoEloChanges query, since I'm only selecting the ones where it is not null.
`The types of '
.result' are incompatible between these types. Type '{ player_id: string | null; elo_change: number; }[]' is not assignable to type { player_id: string; elo_change: number; }[]'.`
Solution
You could do this:
  const blackPlayerTwoEloChanges = db
    .select({
      player_id: sql<string>`${matches.blackPlayerTwo}`,
      elo_change: matches.blackEloChange,
    })
    .from(matches)
    .where(isNotNull(matches.blackPlayerTwo));
Was this page helpful?