Change8

rel_2_0_42

📦 sqlalchemyView on GitHub →
7 features🐛 8 fixes🔧 12 symbols

Summary

SQLAlchemy 2.0.42 adds dataclass metadata support, new loader options for composites, enhanced execution‑parameter validation, a VALUES‑CTE helper, PostgreSQL 14+ JSONB subscripting, and numerous bug fixes across ORM, SQL compilation, and dialects.

✨ New Features

  • Added `dataclass_metadata` argument to ORM attribute constructors such as `mapped_column` and `relationship`, passing through to dataclass field metadata.
  • Implemented `_orm.defer()`, `_orm.undefer()`, and `_orm.load_only()` loader options for composite attributes.
  • Improved validation of execution parameters for `_engine.Connection.execute()` and related methods, providing clearer errors for tuple inputs.
  • Added `_sql.Values.cte()` method to create named CTEs from unnamed VALUES expressions.
  • Supported PostgreSQL 14+ native JSONB subscripting syntax (`jsonb_col['key']`) for read/write operations.
  • Introduced `postgresql_ops` key in reflected dictionary's `dialect_options` to specify column operator classes.
  • Reworked SQL Server column reflection to use `sys.columns` and `object_id()` , fixing comment alignment and handling of special table names, identity, and computed columns.

🐛 Bug Fixes

  • Fixed ORM UPDATE bug where wrong column could be pulled into UPDATE when a key name matched an ORM entity not representing the target table.
  • Fixed `select()` of scalar expressions with unary operators not applying result processors.
  • Hardened UPDATE statement compilation for multi-table updates, raising explicit errors for unsupported secondary tables and improving checks on MySQL.
  • Fixed PostgreSQL constraint reflection regression on older versions (e.g., 9.6) introduced by ticket #10665.
  • Re‑raised caught `CancelledError` in asyncpg dialect's terminate method to prevent hangs.
  • Fixed PostgreSQL reflection bug that misidentified domain or enum types starting with `interval` as `INTERVAL`.
  • Fixed MySQL DEFAULT rendering regression for `CURRENT_TIMESTAMP` with fractional seconds inside textual defaults.
  • Improved SQL Server column reflection to correctly handle comments, special table names, and temporary tables.

Affected Symbols