]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Remove needless clauseelement check for batch
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 24 Feb 2020 19:45:38 +0000 (14:45 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 24 Feb 2020 19:47:01 +0000 (14:47 -0500)
Also document more detail as to why SQL expression support
is not turned on for batch.

Fixes: #5165
Change-Id: Ia93bbf75f22b8781400086c45b86a60ef9cec360
(cherry picked from commit 88c23da948e76b1c273b6c48389d6671878696eb)

doc/build/orm/persistence_techniques.rst
lib/sqlalchemy/orm/persistence.py

index 0a40e77956cc3352d3838252aee5329f1b8fd1af..34703bfbe211eaca63d7d1b79a2248ee71998010 100644 (file)
@@ -772,7 +772,10 @@ are **not available** when using these methods:
 
 * Functionality related to primary key mutation, ON UPDATE cascade
 
-* SQL expression inserts / updates (e.g. :ref:`flush_embedded_sql_expressions`)
+* SQL expression inserts / updates (e.g. :ref:`flush_embedded_sql_expressions`) -
+  having to evaluate these would prevent INSERT and UPDATE statements from
+  being batched together in a straightforward way for a single executemany()
+  call as they alter the SQL compilation of the statement itself.
 
 * ORM events such as :meth:`.MapperEvents.before_insert`, etc.  The bulk
   session methods have no event support.
index 79e7c89c33d8359300b0e13edc7d535c4f425978..28a612068380fc309f438296488d86e2262a05b6 100644 (file)
@@ -502,9 +502,8 @@ def _collect_insert_commands(
             col = propkey_to_col[propkey]
             if value is None and col not in eval_none and not render_nulls:
                 continue
-            elif (
-                not bulk
-                and hasattr(value, "__clause_element__")
+            elif not bulk and (
+                hasattr(value, "__clause_element__")
                 or isinstance(value, sql.ClauseElement)
             ):
                 value_params[col] = (