diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-09-11 10:50:58 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-09-11 10:50:58 -0400 |
| commit | fe6c3605df25d083c20f39fbd176a0c0a6736056 (patch) | |
| tree | cd8c1b82ccd2126cc8e80aa683b033a3074e7943 /lib/sqlalchemy/orm | |
| parent | 96bb6dc56d1da2b4fa30afd08ac4dfa665752913 (diff) | |
| download | sqlalchemy-fe6c3605df25d083c20f39fbd176a0c0a6736056.tar.gz | |
Emit deprecation warning for **kw passed to session.execute()
Passing keyword arguments to methods such as :meth:`_orm.Session.execute`
to be passed into the :meth:`_orm.Session.get_bind` method is deprecated;
the new :paramref:`_orm.Session.execute.bind_arguments` dictionary should
be passed instead.
Fixes: #5573
Change-Id: I555bda84384dbf6d12ba4483c486f9488be0fa25
Diffstat (limited to 'lib/sqlalchemy/orm')
| -rw-r--r-- | lib/sqlalchemy/orm/session.py | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py index 0c012d7f3..535f030cf 100644 --- a/lib/sqlalchemy/orm/session.py +++ b/lib/sqlalchemy/orm/session.py @@ -1561,10 +1561,18 @@ class Session(_SessionClassMethods): """ statement = coercions.expect(roles.CoerceTextStatementRole, statement) - if not bind_arguments: - bind_arguments = kw - elif kw: - bind_arguments.update(kw) + if kw: + util.warn_deprecated_20( + "Passing bind arguments to Session.execute() as keyword " + "arguments is deprecated and will be removed SQLAlchemy 2.0. " + "Please use the bind_arguments parameter." + ) + if not bind_arguments: + bind_arguments = kw + else: + bind_arguments.update(kw) + elif not bind_arguments: + bind_arguments = {} if future and ( statement._propagate_attrs.get("compile_state_plugin", None) @@ -1645,15 +1653,18 @@ class Session(_SessionClassMethods): self, statement, params=None, - execution_options=None, - mapper=None, - bind=None, + execution_options=util.EMPTY_DICT, + bind_arguments=None, **kw ): """Like :meth:`~.Session.execute` but return a scalar result.""" return self.execute( - statement, params=params, mapper=mapper, bind=bind, **kw + statement, + params=params, + execution_options=execution_options, + bind_arguments=bind_arguments, + **kw ).scalar() def close(self): |
