SQLAlchemy rel_2_1_0b2

rel_2_1_0b2Pre-release

2.1.0b2

2.1.0b2

Released: April 16, 2026

orm
  • [orm] [usecase] The metadata, type_annotation_map, or registry can now be set up in a declarative base also via a mixin class, not only by directly setting them on the subclass like before. The declarative class setup now uses getattr() to look for these attributes, instead of relying only on the class __dict__.

    References: #13198

sql
  • [sql] [usecase] Added new parameter _sql.over.exclude to _sql.over() and related methods, enabling SQL standard frame exclusion clauses EXCLUDE CURRENT ROW, EXCLUDE GROUP, EXCLUDE TIES, EXCLUDE NO OTHERS in window functions. Pull request courtesy of Varun Chawla.

    References: #11671

  • [sql] [usecase] The ColumnCollection class hierarchy has been refactored to allow column names such as add, remove, update, extend, and clear to be used without conflicts. ColumnCollection is now an abstract base class, with mutation operations moved to WriteableColumnCollection and DedupeColumnCollection subclasses. The ReadOnlyColumnCollection exposed as attributes such as Table.c no longer includes mutation methods that raised NotImplementedError, allowing these common column names to be accessed naturally, e.g. table.c.add, table.c.remove, table.c.update, etc.

  • [sql] [bug] A warning is emitted when using the standalone _sql.distinct() function in a _sql.select() columns list outside of an aggregate function; this function is not intended as a replacement for the use of Select.distinct(). Pull request courtesy bekapono.

    References: #11526

  • [sql] [bug] Improved the ability for TypeDecorator to produce a correct repr() for "schema" types such as Enum and Boolean. This is mostly to support the Alembic autogenerate use case so that custom types render with relevant arguments present. Improved the architecture used by TypeEngine to produce repr() strings to be more modular for compound types like TypeDecorator.

    References: #13140

schema
  • [schema] [usecase] Most _sql.FromClause subclasses are now generic on _schema.TypedColumns subclasses, that can be used to type their _sql.FromClause.c collection. This applied to _schema.Table, _sql.Join, _sql.Subquery, _sql.CTE and more.

    References: #13085

  • [schema] [bug] Amended the repr() output for Enum so that the MetaData is not shown in the output, as this interferes with Alembic-autogenerated forms of this type which should be inheriting the MetaData of the parent table in the migration script.

    References: #10604

typing
  • [typing] [bug] Fixed issue in new PEP 646 support for result sets where an issue in the mypy type checker prevented "scalar" methods including Connection.scalar(), Result.scalar(), _orm.Session.scalar(), as well as async versions of these methods from applying the correct type to the scalar result value, when the columns in the originating _sql.select() were typed as Any. Pull request courtesy Yurii Karabas.

    References: #13091

  • [typing] [bug] Improved typing of _sqltypes.JSON as well as dialect specific variants like _postgresql.JSON to include generic capabilities, so that the types may be parameterized to indicate any specific type of contents expected, e.g. JSONB[list[str]]().

    References: #13131

mssql
  • [mssql] [feature] Added support for the mssql-python driver, Microsoft's official Python driver for SQL Server.

    References: #12869

oracle
  • [oracle] [feature] Added support for the _sqltypes.JSON datatype when using the Oracle database with the oracledb dialect. JSON values are serialized and deserialized using configurable strategies that accommodate Oracle's native JSON type available as of Oracle 21c. Pull request courtesy Abdallah Alhadad.

    References: #10375

View original

Upgraded? How did it go?

Discussion