Skip to content

2.1.0rc2

Pre-release
Pre-release

Choose a tag to compare

@sqla-tester sqla-tester released this 08 Sep 18:48
· 72 commits to main since this release

2.1.0rc2

Released: September 8, 2026

orm

  • [orm] [usecase] The collection of per-mapper / per-table binds established by the
    _orm.Session.binds parameter, as well as by the
    _orm.Session.bind_mapper() and _orm.Session.bind_table()
    methods, is now available publicly as _orm.Session.binds; the
    collection was previously stored under a private, name-mangled attribute.
    It is an immutable dictionary, and is replaced rather than mutated when a
    new bind is added, so a reference to it will not observe subsequent
    changes. The collection is also proxied by
    _orm.scoping.scoped_session.

    References: #13563

  • [orm] [bug] Fixed issue where an expression passed to _orm.with_expression()
    that embedded a _sql.select(), such as a correlated
    _sql.exists(), would fail to populate the attribute correctly on
    the second and subsequent executions of an otherwise identical
    statement, when the _orm.query_expression() attribute was loaded
    by a relationship loader that emits a second query, i.e.
    _orm.selectinload(), _orm.lazyload() or
    _orm.immediateload().

    This change is also backported to: 2.0.53

    References: #13560

  • [orm] [bug] Fixed memory issue where mapped classes, along with their
    Table and _orm.Mapper objects, would not be garbage
    collected after the _orm.registry in which they were mapped had
    been disposed and dereferenced. The issue would occur for mappings that
    made use of _orm.relationship() together with constructs such as an
    Index established against an ORM-annotated expression.

    This change is also backported to: 2.0.53

    References: #13566

orm declarative

  • [bug] [orm declarative] Fixed memory issue where a declarative class making use of the
    __declare_first__() or __declare_last__() hooks could never be
    garbage collected, as each such class established its own permanent
    _orm.Mapper-wide event listener referring to it. These hooks
    are now invoked by _orm.registry-local RegistryEvents
    listeners which refer to the classes weakly, and which are invoked only
    for the _orm.registry being configured. As the hooks are now
    located as the class is added to the _orm.registry, they also
    take effect for classes mapped using
    _orm.registry.map_imperatively().

    References: #9147

engine

  • [engine] [changed] Improved the implementation of _pool.Pool to use
    weakref.finalize() instead of a weakref.ref() finalizer to handle
    GC cleanup of non-detached, pooled connections that were not explicitly
    closed.

asyncio

  • [asyncio] [usecase] _asyncio.AsyncSession.bind and
    _asyncio.AsyncSession.binds are now always present and are
    derived from the underlying _asyncio.AsyncSession.sync_session,
    translated back into their asyncio equivalents. Added
    _asyncio.AsyncSession.get_async_bind(),
    _asyncio.AsyncSession.bind_mapper() and
    _asyncio.AsyncSession.bind_table() as the asyncio-facing
    counterparts to the _orm.Session methods of the same name.
    Both attributes, along with
    _asyncio.AsyncSession.get_async_bind(), are proxied by
    _asyncio.async_scoped_session.

    References: #13563

sqlite

  • [sqlite] [usecase] [reflection] Implemented _engine.Inspector.get_table_options() for the SQLite
    dialect, which previously raised NotImplementedError. The method
    returns the sqlite_with_rowid and sqlite_strict dialect options
    for a table that was created using the WITHOUT ROWID and / or
    STRICT keywords. As a result, these keywords are now also present in
    _schema.Table.kwargs for a _schema.Table that is
    reflected using autoload, so that a table which is recreated from its
    reflected form, such as by Alembic's batch migration mode, renders the
    keywords again rather than silently dropping them.

    This change is also backported to: 2.0.53

    References: #13543

  • [sqlite] [bug] [reflection] Reworked the regular expression that parses FOREIGN KEY constraints
    during SQLite CREATE TABLE reflection so that the referred column list
    is matched unambiguously avoiding potential exponential backtracking.
    Pull request courtesy of Javid Khan.

    This change is also backported to: 2.0.53

    References: #13530