mirror of
https://github.com/django/django.git
synced 2025-10-29 08:36:09 +00:00
Fixed #26500 -- Added SKIP LOCKED support to select_for_update().
Thanks Tim for the review.
This commit is contained in:
@@ -835,15 +835,18 @@ class QuerySet(object):
|
||||
else:
|
||||
return self._filter_or_exclude(None, **filter_obj)
|
||||
|
||||
def select_for_update(self, nowait=False):
|
||||
def select_for_update(self, nowait=False, skip_locked=False):
|
||||
"""
|
||||
Returns a new QuerySet instance that will select objects with a
|
||||
FOR UPDATE lock.
|
||||
"""
|
||||
if nowait and skip_locked:
|
||||
raise ValueError('The nowait option cannot be used with skip_locked.')
|
||||
obj = self._clone()
|
||||
obj._for_write = True
|
||||
obj.query.select_for_update = True
|
||||
obj.query.select_for_update_nowait = nowait
|
||||
obj.query.select_for_update_skip_locked = skip_locked
|
||||
return obj
|
||||
|
||||
def select_related(self, *fields):
|
||||
|
||||
Reference in New Issue
Block a user