summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/loading.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2017-05-15 09:39:19 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2017-05-24 16:23:56 -0400
commitde11c5217b4c62f86dfd05a28689159095ab1024 (patch)
tree0b1521f3f770f47ea209c4a45ab51a7f225e2fca /lib/sqlalchemy/orm/loading.py
parent9a37503bbedcb958e515ea91c2322efb96bf2680 (diff)
downloadsqlalchemy-de11c5217b4c62f86dfd05a28689159095ab1024.tar.gz
Add with_for_update() support in session.refresh()
Session.refresh() is still hardcoded to legacy lockmode, come up with a new API so that the newer argument style works with it. Added new argument :paramref:`.with_for_update` to the :meth:`.Session.refresh` method. When the :meth:`.Query.with_lockmode` method were deprecated in favor of :meth:`.Query.with_for_update`, the :meth:`.Session.refresh` method was never updated to reflect the new option. Change-Id: Ia02a653746b7024699b515451525a88d7a17d63a Fixes: #3991
Diffstat (limited to 'lib/sqlalchemy/orm/loading.py')
-rw-r--r--lib/sqlalchemy/orm/loading.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/sqlalchemy/orm/loading.py b/lib/sqlalchemy/orm/loading.py
index 3733d50e1..7feec660d 100644
--- a/lib/sqlalchemy/orm/loading.py
+++ b/lib/sqlalchemy/orm/loading.py
@@ -169,7 +169,7 @@ def get_from_identity(session, key, passive):
def load_on_ident(query, key,
- refresh_state=None, lockmode=None,
+ refresh_state=None, with_for_update=None,
only_load_props=None):
"""Load the given identity key from the database."""
@@ -209,9 +209,10 @@ def load_on_ident(query, key,
q._params = params
- if lockmode is not None:
+ # with_for_update needs to be query.LockmodeArg()
+ if with_for_update is not None:
version_check = True
- q = q.with_lockmode(lockmode)
+ q._for_update_arg = with_for_update
elif query._for_update_arg is not None:
version_check = True
q._for_update_arg = query._for_update_arg