summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/crud.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-07-21 11:18:01 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-07-21 13:57:22 -0400
commita34a4af8a80f4edd12b022753b69065025818e20 (patch)
tree379a4060304439f46a6515b9b8c6cd74553c477e /lib/sqlalchemy/sql/crud.py
parente7119aea7870f0322e78d3a2cb28337b1640f0c2 (diff)
downloadsqlalchemy-a34a4af8a80f4edd12b022753b69065025818e20.tar.gz
implement cache key for return_defaults token
Fixed critical caching issue where the ORM's persistence feature using INSERT..RETURNING would cache an incorrect query when mixing the "bulk save" and standard "flush" forms of INSERT. Fixes: #6793 Change-Id: Ifeb61c1226d3fa6d5e1c2e29b6f5ff77a27d6a2d
Diffstat (limited to 'lib/sqlalchemy/sql/crud.py')
-rw-r--r--lib/sqlalchemy/sql/crud.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/sqlalchemy/sql/crud.py b/lib/sqlalchemy/sql/crud.py
index 74f5a1d05..b8f8cb4ce 100644
--- a/lib/sqlalchemy/sql/crud.py
+++ b/lib/sqlalchemy/sql/crud.py
@@ -760,7 +760,7 @@ def _append_param_update(
compiler.postfetch.append(c)
elif (
implicit_return_defaults
- and stmt._return_defaults is not True
+ and (stmt._return_defaults_columns or not stmt._return_defaults)
and c in implicit_return_defaults
):
compiler.returning.append(c)
@@ -1024,10 +1024,10 @@ def _get_returning_modifiers(compiler, stmt, compile_state):
implicit_return_defaults = False # pragma: no cover
if implicit_return_defaults:
- if stmt._return_defaults is True:
+ if not stmt._return_defaults_columns:
implicit_return_defaults = set(stmt.table.c)
else:
- implicit_return_defaults = set(stmt._return_defaults)
+ implicit_return_defaults = set(stmt._return_defaults_columns)
postfetch_lastrowid = need_pks and compiler.dialect.postfetch_lastrowid