Change8

rel_2_1_0b1

📦 sqlalchemyView on GitHub →
10 features1 deprecations🔧 32 symbols

Summary

This release introduces support for free-threaded Python wheels and significant ORM enhancements, including new session execution options and improved composite attribute handling. It also drops support for Python versions older than 3.10.

Migration Steps

  1. If using asyncio features, explicitly install with `sqlalchemy[asyncio]` to include the `greenlet` dependency, as it is no longer installed by default.
  2. Update code to use `_orm.Session.merge_all()` or `_orm.Session.delete_all()` instead of using the deprecated `_orm.Session.flush.objects` parameter.

✨ New Features

  • Free-threaded Python versions are now supported in wheels released on Pypi.
  • The `_orm.relationship.back_populates` argument to `_orm.relationship()` may now be passed as a Python callable, which resolves to either the direct linked ORM attribute, or a string value as before.
  • Added new hybrid method `hybrid_property.bulk_dml()` which works in a similar way as `hybrid_property.update_expression()` for bulk ORM operations.
  • Added new parameter `_orm.composite.return_none_on` to `_orm.composite()`, which allows control over if and when this composite attribute should resolve to `None` when queried or retrieved from the object directly.
  • Added support for per-session execution options that are merged into all queries executed within that session via the `_orm.Session.execution_options` parameter in session constructors.
  • Session autoflush behavior has been simplified to unconditionally flush the session each time an execution takes place, regardless of whether an ORM statement or Core statement is being executed.
  • Added `_orm.RegistryEvents` event class that allows event listeners to be established on a `_orm.registry` object, including `resolve_type_annotation()`, `before_configured()`, and `after_configured()` events.
  • Added the utility method `_orm.Session.merge_all()` and `_orm.Session.delete_all()` that operate on a collection of instances.
  • Added support for using `_orm.with_expression()` to populate a `_orm.query_expression()` attribute that is also configured as the `polymorphic_on` discriminator column.
  • Added default implementations of `ColumnOperators.desc()`, `ColumnOperators.asc()`, `ColumnOperators.nulls_first()`, `ColumnOperators.nulls_last()` to `_orm.composite()` attributes, by default applying the modifier to all contained columns.

Affected Symbols

⚡ Deprecations

  • The `_orm.Session.flush.objects` parameter is now deprecated.