summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-03-31 16:53:43 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2022-03-31 17:02:51 -0400
commit00b37e1462ad6aa4b85d3eec7d07a90a7b6c480c (patch)
tree8ec5fb24af1197a90cc5db59598653106714fa0c /lib/sqlalchemy/sql/compiler.py
parente6d783b293095030c864292ed3c67402497c4174 (diff)
downloadsqlalchemy-00b37e1462ad6aa4b85d3eec7d07a90a7b6c480c.tar.gz
allow executemany values for ON CONFLICT DO NOTHING
Scaled back a fix made for :ticket:`6581` where "executemany values" mode for psycopg2 were disabled for all "ON CONFLICT" styles of INSERT, to not apply to the "ON CONFLICT DO NOTHING" clause, which does not include any parameters and is safe for "executemany values" mode. "ON CONFLICT DO UPDATE" is still blocked from "executemany values" as there may be additional parameters in the DO UPDATE clause that cannot be batched (which is the original issue fixed by :ticket:`6581`). Fixes: #7880 Change-Id: Id3e23a0c6699333409a50148fa8923cb8e564bdc (cherry picked from commit cc8c5835a92b0035530b541c81b0c714b570b095)
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r--lib/sqlalchemy/sql/compiler.py9
1 files changed, 1 insertions, 8 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index 671ca6749..7393629a4 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -3930,14 +3930,7 @@ class SQLCompiler(Compiled):
[value for c, expr, value in crud_params]
)
text += " VALUES (%s)" % insert_single_values_expr
- if toplevel and insert_stmt._post_values_clause is None:
- # don't assign insert_single_values_expr if _post_values_clause
- # is present. what this means concretely is that the
- # "fast insert executemany helper" won't be used, in other
- # words we won't convert "executemany()" of many parameter
- # sets into a single INSERT with many elements in VALUES.
- # We can't apply that optimization safely if for example the
- # statement includes a clause like "ON CONFLICT DO UPDATE"
+ if toplevel:
self.insert_single_values_expr = insert_single_values_expr
if insert_stmt._post_values_clause is not None: