diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-04-26 13:30:29 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-04-26 14:59:15 -0400 |
commit | 87b551c26014c2bf2406ebebb47ee9d3769da9bb (patch) | |
tree | 5cd1d3384022e6c9e99c1255806a091ec7da2c2a /lib/sqlalchemy/sql/crud.py | |
parent | 1443945e61f1f113e46a5044315a91558d4d232a (diff) | |
download | sqlalchemy-87b551c26014c2bf2406ebebb47ee9d3769da9bb.tar.gz |
Handle Sequence in _process_multiparam_default_bind
Fixed issue where usage of an explicit :class:`.Sequence` would produce
inconsistent "inline" behavior for an :class:`.Insert` construct that
includes multiple values phrases; the first seq would be inline but
subsequent ones would be "pre-execute", leading to inconsistent sequence
ordering. The sequence expressions are now fully inline.
Fixes: #6361
Change-Id: Ie16794ec0e19979a7e6c8d1bef5716a9fc199889
Diffstat (limited to 'lib/sqlalchemy/sql/crud.py')
-rw-r--r-- | lib/sqlalchemy/sql/crud.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/crud.py b/lib/sqlalchemy/sql/crud.py index 5fa82bcd0..25dc0d232 100644 --- a/lib/sqlalchemy/sql/crud.py +++ b/lib/sqlalchemy/sql/crud.py @@ -803,7 +803,6 @@ class _multiparam_column(elements.ColumnElement): def _process_multiparam_default_bind(compiler, stmt, c, index, kw): - if not c.default: raise exc.CompileError( "INSERT value for column %s is explicitly rendered as a bound" @@ -812,6 +811,16 @@ def _process_multiparam_default_bind(compiler, stmt, c, index, kw): ) elif c.default.is_clause_element: return compiler.process(c.default.arg.self_group(), **kw) + elif c.default.is_sequence: + # these conditions would have been established + # by append_param_insert_(?:hasdefault|pk_returning|pk_no_returning) + # in order for us to be here, so these don't need to be + # checked + # assert compiler.dialect.supports_sequences and ( + # not c.default.optional + # or not compiler.dialect.sequences_optional + # ) + return compiler.process(c.default, **kw) else: col = _multiparam_column(c, index) if isinstance(stmt, dml.Insert): |