Change8

rel_2_0_50

📦 sqlalchemyView on GitHub →
🐛 10 fixes🔧 18 symbols

Summary

This release focuses primarily on bug fixes across the ORM, SQL expression compilation, and database dialects (PostgreSQL, MySQL, SQLite). Key fixes address incorrect SQL generation in complex ORM queries and improved handling of execution options during ORM events.

Migration Steps

  1. If using PostgreSQL with two-phase commit identifiers provided by the user, note that the psycopg dialect now uses the DBAPI two phase transaction API instead of executing SQL directly.

🐛 Bug Fixes

  • Fixed issue where using `_orm.joinedload()` with `PropComparator.of_type()` targeting a joined-table subclass combined with `PropComparator.and_()` referencing a column on that subclass would generate invalid SQL.
  • Fixed issue where the presence of a `SessionEvents.do_orm_execute()` event hook would cause internal execution options to leak between compilation passes, leading to errors with relationship loaders like `selectinload()` and `immediateload()`. Execution options are now correctly scoped.
  • Fixed issue where using `_orm.with_polymorphic()` on a leaf or non-inherited class failed with an `AttributeError` because mapper configuration was not triggered; `AliasedInsp` now triggers configuration via `_post_inspect` hook.
  • Fixed issue where floor division (`//`) between a `Float` or `Numeric` numerator and an `Integer` denominator omitted the `FLOOR()` SQL wrapper on dialects where `Dialect.div_is_floordiv` is true.
  • Improved handling of two phase transaction identifiers for PostgreSQL when provided by the user by updating the psycopg dialect to use the DBAPI two phase transaction API.
  • Fixed issue where the asyncpg dialect could throw an unhandled `InternalClientError`, preventing connections from being marked as invalidated.
  • Fixed issue where the `ExcludeConstraint` construct did not correctly forward the `ExcludeConstraint.info` parameter, causing lost user-defined metadata.
  • Narrowed the scope of the internal workaround for MySQL bugs [#88718] and [#96365] to only apply to MySQL 8.0.1 through 8.0.13 or systems with `lower_case_table_names=2`, preventing a `KeyError` during foreign key reflection on newer versions.
  • Fixed issue in aiomysql and asyncmy dialects where logic detecting the signature of pymysql's `ping()` method (added in [#10492]) was not correctly handled, appearing since pymysql 1.2.0.
  • Escaped key and pragma values when utilizing the pysqlcipher dialect in SQLite.

Affected Symbols