rel_2_1_0b1
📦 sqlalchemyView on GitHub →
✨ 10 features⚡ 1 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
- If using asyncio features, explicitly install with `sqlalchemy[asyncio]` to include the `greenlet` dependency, as it is no longer installed by default.
- 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
_orm.relationship_orm.relationship.back_populateshybrid_property.bulk_dmlhybrid_property.update_expression_sql.from_dml_column_orm.composite_orm.composite.return_none_on_orm.Session_orm.sessionmaker_orm.scoped_session_ext.asyncio.AsyncSession_ext.asyncio.async_sessionmaker_orm.Session.execution_options_orm.Session.execute_orm.Session.get_orm.Session.scalars_orm.Session.flush.objects_orm.Session.merge_all_orm.Session.delete_all_orm.with_expression_orm.query_expressionpolymorphic_onColumnOperators.descColumnOperators.ascColumnOperators.nulls_firstColumnOperators.nulls_last_orm.aliased_orm.RegistryEvents_orm.RegistryEvents.resolve_type_annotationregistry.type_annotation_map_orm.RegistryEvents.before_configured_orm.RegistryEvents.after_configured
⚡ Deprecations
- The `_orm.Session.flush.objects` parameter is now deprecated.