Skip to content

Commit a0376de

Browse files
dedupe command: fix NoneType on empty set of models (#11998)
1 parent bcaec35 commit a0376de

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

dojo/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,17 +2228,18 @@ def mass_model_updater(model_type, models, function, fields, page_size=1000, ord
22282228
the first X items.
22292229
"""
22302230
# force ordering by id to make our paging work
2231-
last_id = None
2231+
last_id = 0
22322232
models = models.order_by()
22332233
if order == "asc":
22342234
logger.debug("ordering ascending")
22352235
models = models.order_by("id")
2236-
last_id = 0
22372236
elif order == "desc":
22382237
logger.debug("ordering descending")
22392238
models = models.order_by("-id")
22402239
# get maximum, which is the first due to descending order
2241-
last_id = models.first().id + 1
2240+
first = models.first()
2241+
if first:
2242+
last_id = models.first().id + 1
22422243
else:
22432244
msg = "order must be asc or desc"
22442245
raise ValueError(msg)

0 commit comments

Comments
 (0)