Always make explicit which tables to lock (#3058)

Co-authored-by: Richard Schreiber <schreiber@rami.io>
This commit is contained in:
Raphael Michel
2023-01-25 11:44:11 +01:00
committed by GitHub
parent 8ca128912e
commit 3c1f3a26cf
16 changed files with 59 additions and 34 deletions

View File

@@ -21,8 +21,9 @@
#
import contextlib
from django.db import transaction
from django.db import connection, transaction
from django.db.models import Aggregate, Expression, Field, Lookup, Value
from django.utils.functional import lazy
class DummyRollbackException(Exception):
@@ -142,3 +143,8 @@ class PostgresWindowFrame(Expression):
"start": self.start.value,
"end": self.end.value,
}
# This is a short-hand for .select_for_update(of=("self,")), that falls back gracefully on databases that don't support
# the SELECT FOR UPDATE OF ... query.
OF_SELF = lazy(lambda: ("self",) if connection.features.has_select_for_update_of else (), tuple)()