.. changelog::
:version: 2.0.5
- :include_notes_from: unreleased_20
+ :released: March 5, 2023
+
+ .. change::
+ :tags: bug, orm
+ :tickets: 9418
+
+ Added constructor arguments to the built-in mapping collection types
+ including :class:`.KeyFuncDict`, :func:`_orm.attribute_keyed_dict`,
+ :func:`_orm.column_keyed_dict` so that these dictionary types may be
+ constructed in place given the data up front; this provides further
+ compatibility with tools such as Python dataclasses ``.asdict()`` which
+ relies upon invoking these classes directly as ordinary dictionary classes.
+
+ .. change::
+ :tags: bug, orm, regression
+ :tickets: 9424
+
+ Fixed multiple regressions due to :ticket:`8372`, involving
+ :func:`_orm.attribute_mapped_collection` (now called
+ :func:`_orm.attribute_keyed_dict`).
+
+ First, the collection was no longer usable with "key" attributes that were
+ not themselves ordinary mapped attributes; attributes linked to descriptors
+ and/or association proxy attributes have been fixed.
+
+ Second, if an event or other operation needed access to the "key" in order
+ to populate the dictionary from an mapped attribute that was not
+ loaded, this also would raise an error inappropriately, rather than
+ trying to load the attribute as was the behavior in 1.4. This is also
+ fixed.
+
+ For both cases, the behavior of :ticket:`8372` has been expanded.
+ :ticket:`8372` introduced an error that raises when the derived key that
+ would be used as a mapped dictionary key is effectively unassigned. In this
+ change, a warning only is emitted if the effective value of the ".key"
+ attribute is ``None``, where it cannot be unambiguously determined if this
+ ``None`` was intentional or not. ``None`` will be not supported as mapped
+ collection dictionary keys going forward (as it typically refers to NULL
+ which means "unknown"). Setting
+ :paramref:`_orm.attribute_keyed_dict.ignore_unpopulated_attribute` will now
+ cause such ``None`` keys to be ignored as well.
+
+ .. change::
+ :tags: engine, performance
+ :tickets: 9343
+
+ A small optimization to the Cython implementation of :class:`.Result`
+ using a cdef for a particular int value to avoid Python overhead. Pull
+ request courtesy Matus Valo.
+
+
+ .. change::
+ :tags: bug, mssql
+ :tickets: 9414
+
+ Fixed issue in the new :class:`.Uuid` datatype which prevented it from
+ working with the pymssql driver. As pymssql seems to be maintained again,
+ restored testing support for pymssql.
+
+ .. change::
+ :tags: bug, mssql
+
+ Tweaked the pymssql dialect to take better advantage of
+ RETURNING for INSERT statements in order to retrieve last inserted primary
+ key values, in the same way as occurs for the mssql+pyodbc dialect right
+ now.
+
+ .. change::
+ :tags: bug, orm
+
+ Identified that the ``sqlite`` and ``mssql+pyodbc`` dialects are now
+ compatible with the SQLAlchemy ORM's "versioned rows" feature, since
+ SQLAlchemy now computes rowcount for a RETURNING statement in this specific
+ case by counting the rows returned, rather than relying upon
+ ``cursor.rowcount``. In particular, the ORM versioned rows use case
+ (documented at :ref:`mapper_version_counter`) should now be fully
+ supported with the SQL Server pyodbc dialect.
+
+
+ .. change::
+ :tags: bug, postgresql
+ :tickets: 9349
+
+ Fixed issue in PostgreSQL :class:`_postgresql.ExcludeConstraint` where
+ literal values were being compiled as bound parameters and not direct
+ inline values as is required for DDL.
+
+ .. change::
+ :tags: bug, typing
+
+ Fixed bug where the :meth:`_engine.Connection.scalars` method was not typed
+ as allowing a multiple-parameters list, which is now supported using
+ insertmanyvalues operations.
+
+ .. change::
+ :tags: bug, typing
+ :tickets: 9376
+
+ Improved typing for the mapping passed to :meth:`.Insert.values` and
+ :meth:`.Update.values` to be more open-ended about collection type, by
+ indicating read-only ``Mapping`` instead of writeable ``Dict`` which would
+ error out on too limited of a key type.
+
+ .. change::
+ :tags: schema
+
+ Validate that when provided the :paramref:`_schema.MetaData.schema`
+ argument of :class:`_schema.MetaData` is a string.
+
+ .. change::
+ :tags: typing, usecase
+ :tickets: 9338
+
+ Exported the type returned by
+ :meth:`_orm.scoped_session.query_property` using a new public type
+ :class:`.orm.QueryPropertyDescriptor`.
+
+ .. change::
+ :tags: bug, mysql, postgresql
+ :tickets: 5648
+
+ The support for pool ping listeners to receive exception events via the
+ :meth:`.DialectEvents.handle_error` event added in 2.0.0b1 for
+ :ticket:`5648` failed to take into account dialect-specific ping routines
+ such as that of MySQL and PostgreSQL. The dialect feature has been reworked
+ so that all dialects participate within event handling. Additionally,
+ a new boolean element :attr:`.ExceptionContext.is_pre_ping` is added
+ which identifies if this operation is occurring within the pre-ping
+ operation.
+
+ For this release, third party dialects which implement a custom
+ :meth:`_engine.Dialect.do_ping` method can opt in to the newly improved
+ behavior by having their method no longer catch exceptions or check
+ exceptions for "is_disconnect", instead just propagating all exceptions
+ outwards. Checking the exception for "is_disconnect" is now done by an
+ enclosing method on the default dialect, which ensures that the event hook
+ is invoked for all exception scenarios before testing the exception as a
+ "disconnect" exception. If an existing ``do_ping()`` method continues to
+ catch exceptions and check "is_disconnect", it will continue to work as it
+ did previously, but ``handle_error`` hooks will not have access to the
+ exception if it isn't propagated outwards.
+
+ .. change::
+ :tags: bug, ext
+ :tickets: 9367
+
+ Fixed issue in automap where calling :meth:`_automap.AutomapBase.prepare`
+ from a specific mapped class, rather than from the
+ :class:`_automap.AutomapBase` directly, would not use the correct base
+ class when automap detected new tables, instead using the given class,
+ leading to mappers trying to configure inheritance. While one should
+ normally call :meth:`_automap.AutomapBase.prepare` from the base in any
+ case, it shouldn't misbehave that badly when called from a subclass.
+
+
+ .. change::
+ :tags: bug, sqlite, regression
+ :tickets: 9379
+
+ Fixed regression for SQLite connections where use of the ``deterministic``
+ parameter when establishing database functions would fail for older SQLite
+ versions, those prior to version 3.8.3. The version checking logic has been
+ improved to accommodate for this case.
+
+ .. change::
+ :tags: bug, typing
+ :tickets: 9391
+
+ Added missing init overload to the :class:`_types.Numeric` type object so
+ that pep-484 type checkers may properly resolve the complete type, deriving
+ from the :paramref:`_types.Numeric.asdecimal` parameter whether ``Decimal``
+ or ``float`` objects will be represented.
+
+ .. change::
+ :tags: bug, typing
+ :tickets: 9398
+
+ Fixed typing bug where :meth:`_sql.Select.from_statement` would not accept
+ :func:`_sql.text` or :class:`.TextualSelect` objects as a valid type.
+ Additionally repaired the :class:`.TextClause.columns` method to have a
+ return type, which was missing.
+
+ .. change::
+ :tags: bug, orm declarative
+ :tickets: 9332
+
+ Fixed issue where new :paramref:`_orm.mapped_column.use_existing_column`
+ feature would not work if the two same-named columns were mapped under
+ attribute names that were differently-named from an explicit name given to
+ the column itself. The attribute names can now be differently named when
+ using this parameter.
+
+ .. change::
+ :tags: bug, orm
+ :tickets: 9373
+
+ Added support for the :paramref:`_orm.Mapper.polymorphic_load` parameter to
+ be applied to each mapper in an inheritance hierarchy more than one level
+ deep, allowing columns to load for all classes in the hierarchy that
+ indicate ``"selectin"`` using a single statement, rather than ignoring
+ elements on those intermediary classes that nonetheless indicate they also
+ would participate in ``"selectin"`` loading and were not part of the
+ base-most SELECT statement.
+
+ .. change::
+ :tags: bug, orm
+ :tickets: 8853, 9335
+
+ Continued the fix for :ticket:`8853`, allowing the :class:`_orm.Mapped`
+ name to be fully qualified regardless of whether or not
+ ``from __annotations__ import future`` were present. This issue first fixed
+ in 2.0.0b3 confirmed that this case worked via the test suite, however the
+ test suite apparently was not testing the behavior for the name
+ :class:`_orm.Mapped` not being locally present at all; string resolution
+ has been updated to ensure the :class:`_orm.Mapped` symbol is locatable as
+ applies to how the ORM uses these functions.
+
+ .. change::
+ :tags: bug, typing
+ :tickets: 9340
+
+ Fixed typing issue where :func:`_orm.with_polymorphic` would not
+ record the class type correctly.
+
+ .. change::
+ :tags: bug, ext, regression
+ :tickets: 9380
+
+ Fixed regression caused by typing added to ``sqlalchemy.ext.mutable`` for
+ :ticket:`8667`, where the semantics of the ``.pop()`` method changed such
+ that the method was non-working. Pull request courtesy Nils Philippsen.
+
+ .. change::
+ :tags: bug, sql, regression
+ :tickets: 9390
+
+ Restore the :func:`.nullslast` and :func:`.nullsfirst` legacy functions
+ into the ``sqlalchemy`` import namespace. Previously, the newer
+ :func:`.nulls_last` and :func:`.nulls_first` functions were available, but
+ the legacy ones were inadvertently removed.
+
+ .. change::
+ :tags: bug, postgresql
+ :tickets: 9401
+
+ Fixed issue where the PostgreSQL :class:`_postgresql.ExcludeConstraint`
+ construct would not be copyable within operations such as
+ :meth:`_schema.Table.to_metadata` as well as within some Alembic scenarios,
+ if the constraint contained textual expression elements.
+
+ .. change::
+ :tags: bug, engine
+ :tickets: 9423
+
+ Fixed bug where :class:`_engine.Row` objects could not be reliably unpickled
+ across processes due to an accidental reliance on an unstable hash value.
.. changelog::
:version: 2.0.4