Better document `expanding=True` on a bind parameter
Author: CaselITCreated Dec 30, 2021Updated Sep 3, 2026
Labelsbugdocumentationsqlstatement caching
From empirical testing, the new caching added in 1.4 does not seem to make use of the expanding argument on bind parameter.
This should be verified and the documentation updated and/or the parameter marked as legacy in the docs (I don't think we would need to deprecate it now, at least for the moment)
Example test script:
import sqlalchemy as sa
e = sa.create_engine("postgresql://scott:tiger@localhost/test", echo=True)
t = sa.table("user", sa.column("id"), sa.column("name"))
s = sa.select(t.c.id, t.c.name).where(t.c.id.in_(sa.bindparam("ids")))
with e.connect() as c:
print(c.execute(s, {"ids": [1]}).all())
print(c.execute(s, {"ids": [2, 3]}).all())
print(c.execute(s, {"ids": [2, 3, 5]}).all())Source: sqlalchemy/sqlalchemy