Skip to content

Commit 4cb4df6

Browse files
committed
fix: guard against race condition in compute_id_ranges
Handle the unlikely case where records are deleted between the COUNT and MIN/MAX queries, which would cause a TypeError on None values.
1 parent 0027c7b commit 4cb4df6

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

spp_programs/models/managers/pagination_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def compute_id_ranges(cr, table, where_clause, params, batch_size):
4343
params,
4444
)
4545
row = cr.fetchone()
46-
return [(row[0], row[1])]
46+
return [(row[0], row[1])] if row and row[0] is not None else []
4747

4848
# Use NTILE to split rows into equal-sized buckets, then get
4949
# the min/max ID of each bucket as the range boundaries.

0 commit comments

Comments
 (0)