Skip to content

Apply tuple bind expressions to expanding IN values - #13323

Open
puneetdixit200 wants to merge 1 commit into
sqlalchemy:mainfrom
puneetdixit200:fix/tuple-bind-expressions
Open

puneetdixit200 wants to merge 1 commit into
sqlalchemy:mainfrom
puneetdixit200:fix/tuple-bind-expressions

Conversation

@puneetdixit200

Copy link
Copy Markdown

Description

Tuple-valued expanding parameters now apply each element type's bind_expression() when rendering expanded tuples. This matches scalar IN behavior for custom types and covers both render_postcompile and literal_binds.

Fixes: #8992

Checklist

This pull request is:

Local checks:

  • uv run --group tests pytest test/sql/test_type_expressions.py -q
  • uv run --group tests pytest test/sql/test_compiler.py -q -k "tuple_expanding_in or expanding_parameter"
  • uv run --group lint flake8 lib/sqlalchemy/sql/compiler.py test/sql/test_type_expressions.py
  • uv run --group lint black --check lib/sqlalchemy/sql/compiler.py test/sql/test_type_expressions.py

bind_expression = impl.bind_expression(
elements.literal_column(replacement, type_=typ)
)
return self.process(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bind_expression() can introduce its own bind params (for example, func.coalesce(bindvalue, "fallback")). Calling self.process() from postcompile expansion then mutates self.binds while _process_parameters_for_postcompile() is iterating it, so this tuple fails compilation with RuntimeError: dictionary changed size during iteration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tuple expanding params do not render bind_expression() for elements

2 participants