diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2021-10-27 14:22:14 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2021-10-27 14:22:14 +0000 |
commit | 51ea54ffe3c7b87593c424c900d1065c6df72639 (patch) | |
tree | 9cd68051eaafdc07282dd272ae2894462b22577d | |
parent | 229588a12c5baedd9ab9b2c7443d7622d7f8ca38 (diff) | |
parent | f3e0bef712da7a40ead247994413b36e5e3dd97b (diff) | |
download | sqlalchemy-51ea54ffe3c7b87593c424c900d1065c6df72639.tar.gz |
Merge "Fixes: #4100" into main
-rw-r--r-- | doc/build/orm/loading_relationships.rst | 10 | ||||
-rw-r--r-- | lib/sqlalchemy/orm/query.py | 9 |
2 files changed, 19 insertions, 0 deletions
diff --git a/doc/build/orm/loading_relationships.rst b/doc/build/orm/loading_relationships.rst index 2734e6870..5a1d5151d 100644 --- a/doc/build/orm/loading_relationships.rst +++ b/doc/build/orm/loading_relationships.rst @@ -444,6 +444,16 @@ On older versions of SQLite, the above nested right JOIN may be re-rendered as a nested subquery. Older versions of SQLAlchemy would convert right-nested joins into subqueries in all cases. + .. warning:: + + Using ``with_for_update`` in the context of eager loading + relationships is not officially supported or recommended by + SQLAlchemy and may not work with certain queries on various + database backends. When ``with_for_update`` is successfully used + with a query that involves :func:`_orm.joinedload`, SQLAlchemy will + attempt to emit SQL that locks all involved tables. + + Joined eager loading and result set batching ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index d48e34923..a2766766b 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -1602,6 +1602,15 @@ class Query( SELECT users.id AS users_id FROM users FOR UPDATE OF users NOWAIT + .. warning:: + + Using ``with_for_update`` in the context of eager loading + relationships is not officially supported or recommended by + SQLAlchemy and may not work with certain queries on various + database backends. When ``with_for_update`` is successfully used + with a query that involves :func:`_orm.joinedload`, SQLAlchemy will + attempt to emit SQL that locks all involved tables. + .. note:: It is generally a good idea to combine the use of the :meth:`_orm.Query.populate_existing` method when using the :meth:`_orm.Query.with_for_update` method. The purpose of |