render bind_expression around each literal_execute expanding value

オープン
#13,732 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@chirag-gupta7 がすでに取り組んでいます。

2026年11月6日 から。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
67/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python, sqlalchemy
領域
databases

調査の方向性

Start by tracing _process_parameters_for_postcompile and the expanding parameter element renderers described in the issue, then compare them with the literal_binds compile path. Reproduce the case with TypeDecorator.bind_expression() and the expanding literal_execute parameter. Done means the emitted SQL keeps 'a, b' intact inside its lower() expression and the compile and round trip tests pass.

索引モデルが issue の本文から書いたものです。

説明

bug sql

Reported by @basavaraj-sm05 in #13730

Description

When an expanding parameter is also marked literal_execute=True and its datatype has a bind_expression(), the values of the IN list are rendered as SQL literals at execution time and joined with ", ", and then _process_parameters_for_postcompile splits that rendered text on ", " again to wrap each piece with the bind expression. That works for bound placeholders, which never contain a comma, but a literal value such as 'a, b' gets torn in half. With a TypeDecorator whose bind_expression is func.lower(...):

stmt = select(t).where(
    t.c.name.in_(bindparam("q", expanding=True, literal_execute=True))
)
conn.execute(stmt, {"q": ["a, b", "c"]})

emits

WHERE t.name IN (lower('a), lower(b'), lower('c'))

and the row holding a, b is silently missing from the result (or wrongly kept by a NOT IN). The literal_binds compile path already handled this correctly by applying the template per value before joining, so this change makes the execution path do the same: the templates for expanding parameters are picked up from the compiled string once and passed down to the element renderers, and process_expanding no longer splits rendered text. Bound placeholder rendering comes out identical to before. Compile level and round trip tests are included along with a changelog entry.

主要言語
Python
スター
12.3k
フォーク
1.8k
平均マージ
2日 10時間
マージ済み PR(30日)
9

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

sqlalchemy/sqlalchemy のほかの issue

sqlalchemy/sqlalchemy の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。