Change8

rel_2_0_39

📦 sqlalchemyView on GitHub →
2 features🐛 10 fixes🔧 23 symbols

Summary

SQLAlchemy 2.0.39 introduces generic typing for compound selects and new constraint isolation parameters, while fixing numerous ORM, asyncio, PostgreSQL, and SQLite bugs.

✨ New Features

  • Support generic types for compound selects (e.g., _sql.union(), _sql.union_all(), _sql.Select.union(), _sql.Select.union_all()) returning the type of the first select.
  • Added new parameters AddConstraint.isolate_from_table and DropConstraint.isolate_from_table (default True) to control inclusion of constraints in CREATE TABLE.

🐛 Bug Fixes

  • Fixed bug where using DML returning such as Insert.returning() with an ORM model having _orm.column_property() subqueries caused an internal error.
  • Fixed bug in ORM-enabled UPDATE (and DELETE) where multi-table DML statements omitted mapped columns from non-primary mappers in the RETURNING clause, causing a column not found exception.
  • Fixed issue where the ORM flag of a select() or other ORM statement was not propagated to the Session when using multi-part operator expressions, leading to missing ORM behaviors.
  • Fixed issue where using _orm.aliased() around a CTE could cause duplicate CTE errors when the aliased construct appeared multiple times in a single statement.
  • Fixed bug where _asyncio.AsyncResult.scalar(), _asyncio.AsyncResult.scalar_one_or_none(), and _asyncio.AsyncResult.scalar_one() raised an AttributeError due to a missing internal attribute.
  • Added explicit JSON typing to the PostgreSQL reflection query for IDENTITY columns to accommodate drivers that lack native JSON support.
  • Fixed reflection of PostgreSQL domains with NOT NULL that incorrectly added an extra NOT NULL constraint; servers 17.0-17.2 still have a PostgreSQL-side bug, so upgrade to 17.3+.
  • Fixed issue in PostgreSQL network types (_postgresql.INET, _postgresql.CIDR, _postgresql.MACADDR, _postgresql.MACADDR8) where string comparisons rendered an explicit CAST to VARCHAR, causing failures in some driver combinations.
  • Fixed compiler issue in the PostgreSQL dialect where incorrect keywords were used for "FOR UPDATE OF" inside subqueries.
  • Fixed SQLite issue that omitted the comma between multiple table extension clauses (WITH ROWID and STRICT) when both Table.sqlite_with_rowid and Table.sqlite_strict are set.

🔧 Affected Symbols

Insert.returning_orm.column_propertyUpdateDeleteselect_orm.aliasedCTEAddConstraint.isolate_from_tableDropConstraint.isolate_from_table_sql.union_sql.union_all_sql.Select.union_sql.Select.union_all_asyncio.AsyncResult.scalar_asyncio.AsyncResult.scalar_one_or_none_asyncio.AsyncResult.scalar_one_postgresql.PGInspector.get_domains_postgresql.INET_postgresql.CIDR_postgresql.MACADDR_postgresql.MACADDR8Table.sqlite_with_rowidTable.sqlite_strict