fix: address review feedback (#52)
Guard bulk ID queries against empty lists to prevent PostgreSQL syntax error (WHERE id IN ()) when batch POST endpoints receive empty request bodies. Affected endpoints: - POST /api/v3/transactions - POST /api/v3/results - POST /api/v3/schedules - POST /api/v3/battingstats Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b0fd1d89ea
commit
a0d5d49724
@ -383,11 +383,15 @@ async def post_batstats(s_list: BatStatList, token: str = Depends(oauth2_scheme)
|
||||
|
||||
all_team_ids = list(set(x.team_id for x in s_list.stats))
|
||||
all_player_ids = list(set(x.player_id for x in s_list.stats))
|
||||
found_team_ids = set(
|
||||
t.id for t in Team.select(Team.id).where(Team.id << all_team_ids)
|
||||
found_team_ids = (
|
||||
set(t.id for t in Team.select(Team.id).where(Team.id << all_team_ids))
|
||||
if all_team_ids
|
||||
else set()
|
||||
)
|
||||
found_player_ids = set(
|
||||
p.id for p in Player.select(Player.id).where(Player.id << all_player_ids)
|
||||
found_player_ids = (
|
||||
set(p.id for p in Player.select(Player.id).where(Player.id << all_player_ids))
|
||||
if all_player_ids
|
||||
else set()
|
||||
)
|
||||
|
||||
for x in s_list.stats:
|
||||
|
||||
@ -164,8 +164,10 @@ async def post_results(result_list: ResultList, token: str = Depends(oauth2_sche
|
||||
set(x.awayteam_id for x in result_list.results)
|
||||
| set(x.hometeam_id for x in result_list.results)
|
||||
)
|
||||
found_team_ids = set(
|
||||
t.id for t in Team.select(Team.id).where(Team.id << all_team_ids)
|
||||
found_team_ids = (
|
||||
set(t.id for t in Team.select(Team.id).where(Team.id << all_team_ids))
|
||||
if all_team_ids
|
||||
else set()
|
||||
)
|
||||
|
||||
for x in result_list.results:
|
||||
|
||||
@ -149,8 +149,10 @@ async def post_schedules(sched_list: ScheduleList, token: str = Depends(oauth2_s
|
||||
set(x.awayteam_id for x in sched_list.schedules)
|
||||
| set(x.hometeam_id for x in sched_list.schedules)
|
||||
)
|
||||
found_team_ids = set(
|
||||
t.id for t in Team.select(Team.id).where(Team.id << all_team_ids)
|
||||
found_team_ids = (
|
||||
set(t.id for t in Team.select(Team.id).where(Team.id << all_team_ids))
|
||||
if all_team_ids
|
||||
else set()
|
||||
)
|
||||
|
||||
for x in sched_list.schedules:
|
||||
|
||||
@ -147,11 +147,15 @@ async def post_transactions(
|
||||
set(x.oldteam_id for x in moves.moves) | set(x.newteam_id for x in moves.moves)
|
||||
)
|
||||
all_player_ids = list(set(x.player_id for x in moves.moves))
|
||||
found_team_ids = set(
|
||||
t.id for t in Team.select(Team.id).where(Team.id << all_team_ids)
|
||||
found_team_ids = (
|
||||
set(t.id for t in Team.select(Team.id).where(Team.id << all_team_ids))
|
||||
if all_team_ids
|
||||
else set()
|
||||
)
|
||||
found_player_ids = set(
|
||||
p.id for p in Player.select(Player.id).where(Player.id << all_player_ids)
|
||||
found_player_ids = (
|
||||
set(p.id for p in Player.select(Player.id).where(Player.id << all_player_ids))
|
||||
if all_player_ids
|
||||
else set()
|
||||
)
|
||||
|
||||
for x in moves.moves:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user