From 87b551c26014c2bf2406ebebb47ee9d3769da9bb Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 26 Apr 2021 13:30:29 -0400 Subject: 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 --- lib/sqlalchemy/sql/crud.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/sql/crud.py') 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): -- cgit v1.2.1