github sqlalchemy/sqlalchemy rel_2_0_20
2.0.20

latest releases: rel_2_0_35, rel_1_4_54, rel_2_0_34...
13 months ago

2.0.20

Released: August 15, 2023

orm

  • [orm] [usecase] Implemented the "RETURNING '*'" use case for ORM enabled DML statements.
    This will render in as many cases as possible and return the unfiltered
    result set, however is not supported for multi-parameter "ORM bulk INSERT"
    statements that have specific column rendering requirements.

    References: #10192

  • [orm] [bug] Fixed fundamental issue which prevented some forms of ORM "annotations"
    from taking place for subqueries which made use of _sql.Select.join()
    against a relationship target. These annotations are used whenever a
    subquery is used in special situations such as within
    _orm.PropComparator.and_() and other ORM-specific scenarios.

    This change is also backported to: 1.4.50

    References: #10223

  • [orm] [bug] Fixed fundamental issue which prevented some forms of ORM "annotations"
    from taking place for subqueries which made use of _sql.Select.join()
    against a relationship target. These annotations are used whenever a
    subquery is used in special situations such as within
    _orm.PropComparator.and_() and other ORM-specific scenarios.

    This change is also backported to: 1.4.50

    References: #10223

  • [orm] [bug] Fixed issue where the ORM's generation of a SELECT from a joined
    inheritance model with same-named columns in superclass and subclass would
    somehow not send the correct list of column names to the CTE
    construct, when the RECURSIVE column list were generated.

    References: #10169

  • [orm] [bug] Fixed fairly major issue where execution options passed to
    _orm.Session.execute(), as well as execution options local to the ORM
    executed statement itself, would not be propagated along to eager loaders
    such as that of _orm.selectinload(), _orm.immediateload(), and
    _orm.subqueryload(), making it impossible to do things such as
    disabling the cache for a single statement or using
    schema_translate_map for a single statement, as well as the use of
    user-custom execution options. A change has been made where all
    user-facing execution options present for _orm.Session.execute() will
    be propagated along to additional loaders.

    As part of this change, the warning for "excessively deep" eager loaders
    leading to caching being disabled can be silenced on a per-statement
    basis by sending execution_options={"compiled_cache": None} to
    _orm.Session.execute(), which will disable caching for the full
    series of statements within that scope.

    References: #10231

  • [orm] [bug] Fixed issue where internal cloning used by the ORM for expressions like
    _orm.relationship.Comparator.any() to produce correlated EXISTS
    constructs would interfere with the "cartesian product warning" feature of
    the SQL compiler, leading the SQL compiler to warn when all elements of the
    statement were correctly joined.

    References: #10124

  • [orm] [bug] Fixed issue where the lazy="immediateload" loader strategy would place
    an internal loading token into the ORM mapped attribute under circumstances
    where the load should not occur, such as in a recursive self-referential
    load. As part of this change, the lazy="immediateload" strategy now
    honors the _orm.relationship.join_depth parameter for
    self-referential eager loads in the same way as that of other eager
    loaders, where leaving it unset or set at zero will lead to a
    self-referential immediateload not occurring, setting it to a value of one
    or greater will immediateload up until that given depth.

    References: #10139

  • [orm] [bug] Fixed issue where dictionary-based collections such as
    _orm.attribute_keyed_dict() did not fully pickle/unpickle correctly,
    leading to issues when attempting to mutate such a collection after
    unpickling.

    References: #10175

  • [orm] [bug] Fixed issue where chaining _orm.load_only() or other wildcard use of
    _orm.defer() from another eager loader using a _orm.aliased()
    against a joined inheritance subclass would fail to take effect for columns
    local to the superclass.

    References: #10125

  • [orm] [bug] Fixed issue where an ORM-enabled _sql.select() construct would not
    render any CTEs added only via the _sql.Select.add_cte() method that
    were not otherwise referenced in the statement.

    References: #10167

examples

  • [examples] [bug] The dogpile_caching examples have been updated for 2.0 style queries.
    Within the "caching query" logic itself there is one conditional added to
    differentiate between Query and select() when performing an
    invalidation operation.

engine

  • [engine] [bug] Fixed critical issue where setting
    _sa.create_engine.isolation_level to AUTOCOMMIT (as opposed
    to using the _engine.Engine.execution_options() method) would fail to
    restore "autocommit" to a pooled connection if an alternate isolation level
    were temporarily selected using
    _engine.Connection.execution_options.isolation_level.

    References: #10147

sql

  • [sql] [bug] Fixed issue where unpickling of a _schema.Column or other
    _sql.ColumnElement would fail to restore the correct "comparator"
    object, which is used to generate SQL expressions specific to the type
    object.

    This change is also backported to: 1.4.50

    References: #10213

  • [sql] [bug] Fixed issue where unpickling of a _schema.Column or other
    _sql.ColumnElement would fail to restore the correct "comparator"
    object, which is used to generate SQL expressions specific to the type
    object.

    This change is also backported to: 1.4.50

    References: #10213

typing

  • [typing] [usecase] Added new typing only utility functions Nullable() and
    NotNullable() to type a column or ORM class as, respectively,
    nullable or not nullable.
    These function are no-op at runtime, returning the input unchanged.

    References: #10173

  • [typing] [bug] Typing improvements:

    -   `CursorResult` is returned for some forms of
        `_orm.Session.execute()` where DML without RETURNING is used
    
    -   fixed type for `_orm.Query.with_for_update.of` parameter within
        `_orm.Query.with_for_update()`
    
    -   improvements to `_DMLColumnArgument` type used by some DML methods to
        pass column expressions
    
    -   Add overload to `_sql.literal()` so that it is inferred that the
        return type is `BindParameter[NullType]` where
        `_sql.literal.type_` param is None
    
    -   Add overloads to `_sql.ColumnElement.op()` so that the inferred
        type when `_sql.ColumnElement.op.return_type` is not provided
        is `Callable[[Any], BinaryExpression[Any]]`
    
    -   Add missing overload to `_sql.ColumnElement.__add__()`
    

    Pull request courtesy Mehdi Gmira.

    References: #9185

  • [typing] [bug] Fixed issue in _orm.Session and _asyncio.AsyncSession
    methods such as _orm.Session.connection() where the
    _orm.Session.connection.execution_options parameter were
    hardcoded to an internal type that is not user-facing.

    References: #10182

asyncio

  • [asyncio] [usecase] Added new methods _asyncio.AsyncConnection.aclose() as a synonym for
    _asyncio.AsyncConnection.close() and
    _asyncio.AsyncSession.aclose() as a synonym for
    _asyncio.AsyncSession.close() to the
    _asyncio.AsyncConnection and _asyncio.AsyncSession
    objects, to provide compatibility with Python standard library
    @contextlib.aclosing construct. Pull request courtesy Grigoriev Semyon.

    References: #9698

mysql

  • [mysql] [usecase] Updated aiomysql dialect since the dialect appears to be maintained again.
    Re-added to the ci testing using version 0.2.0.

    This change is also backported to: 1.4.50

Don't miss a new sqlalchemy release

NewReleases is sending notifications on new releases.