diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-02-24 14:45:38 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-02-24 14:45:38 -0500 |
commit | 88c23da948e76b1c273b6c48389d6671878696eb (patch) | |
tree | 3a0250979f7c08f7c98dbf3e38e392976caba0d4 | |
parent | 5d42051c2e575713ffb8ea4f43ef1c2145b83c97 (diff) | |
download | sqlalchemy-88c23da948e76b1c273b6c48389d6671878696eb.tar.gz |
Remove needless clauseelement check for batch
Also document more detail as to why SQL expression support
is not turned on for batch.
Fixes: #5165
Change-Id: Ia93bbf75f22b8781400086c45b86a60ef9cec360
-rw-r--r-- | doc/build/orm/persistence_techniques.rst | 5 | ||||
-rw-r--r-- | lib/sqlalchemy/orm/persistence.py | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/doc/build/orm/persistence_techniques.rst b/doc/build/orm/persistence_techniques.rst index 0a40e7795..34703bfbe 100644 --- a/doc/build/orm/persistence_techniques.rst +++ b/doc/build/orm/persistence_techniques.rst @@ -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. diff --git a/lib/sqlalchemy/orm/persistence.py b/lib/sqlalchemy/orm/persistence.py index 95c5f8fa2..3b274a389 100644 --- a/lib/sqlalchemy/orm/persistence.py +++ b/lib/sqlalchemy/orm/persistence.py @@ -506,9 +506,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] = ( |