2.0.10
2.0.10
Released: April 21, 2023
orm
-
[orm] [bug] Fixed bug where various ORM-specific getters such as
ORMExecuteState.is_column_load,
ORMExecuteState.is_relationship_load,
ORMExecuteState.loader_strategy_pathetc. would throw an
AttributeErrorif the SQL statement itself were a "compound select"
such as a UNION.This change is also backported to: 1.4.48
References: #9634
-
[orm] [bug] Fixed bug where various ORM-specific getters such as
ORMExecuteState.is_column_load,
ORMExecuteState.is_relationship_load,
ORMExecuteState.loader_strategy_pathetc. would throw an
AttributeErrorif the SQL statement itself were a "compound select"
such as a UNION.This change is also backported to: 1.4.48
References: #9634
-
[orm] [bug] Fixed issue where the
_orm.declared_attr.directive()modifier was not
correctly honored for subclasses when applied to the__mapper_args__
special method name, as opposed to direct use of
_orm.declared_attr. The two constructs should have identical
runtime behaviors.References: #9625
-
[orm] [bug] Made an improvement to the
_orm.with_loader_criteria()loader option
to allow it to be indicated in theExecutable.options()method of a
top-level statement that is not itself an ORM statement. Examples include
_sql.select()that's embedded in compound statements such as
_sql.union(), within an_dml.Insert.from_select()construct, as
well as within CTE expressions that are not ORM related at the top level.References: #9635
-
[orm] [bug] Fixed bug in ORM bulk insert feature where additional unnecessary columns
would be rendered in the INSERT statement if RETURNING of individual columns
were requested.References: #9685
-
[orm] [bug] Fixed bug in ORM Declarative Dataclasses where the
_orm.query_expression()and_orm.column_property()
constructs, which are documented as read-only constructs in the context of
a Declarative mapping, could not be used with a
_orm.MappedAsDataclassclass without addinginit=False, which
in the case of_orm.query_expression()was not possible as no
initparameter was included. These constructs have been modified from a
dataclass perspective to be assumed to be "read only", setting
init=Falseby default and no longer including them in the pep-681
constructor. The dataclass parameters for_orm.column_property()
init,default,default_factory,kw_onlyare now deprecated;
these fields don't apply to_orm.column_property()as used in a
Declarative dataclasses configuration where the construct would be
read-only. Also added read-specific parameter
_orm.query_expression.compareto
_orm.query_expression();_orm.query_expression.repr
was already present.References: #9628
-
[orm] [bug] Added missing
_orm.mapped_column.active_historyparameter
to_orm.mapped_column()construct.
engine
-
[engine] [usecase] Added
_sa.create_pool_from_url()and
_asyncio.create_async_pool_from_url()to create
a_pool.Poolinstance from an input url passed as string
or_sa.URL.References: #9613
-
[engine] [bug] Repaired a major shortcoming which was identified in the
engine_insertmanyvaluesperformance optimization feature first
introduced in the 2.0 series. This was a continuation of the change in
2.0.9 which disabled the SQL Server version of the feature due to a
reliance in the ORM on apparent row ordering that is not guaranteed to take
place. The fix applies new logic to all "insertmanyvalues" operations,
which takes effect when a new parameter
_dml.Insert.returning.sort_by_parameter_orderon the
_dml.Insert.returning()or_dml.UpdateBase.return_defaults()
methods, that through a combination of alternate SQL forms, direct
correspondence of client side parameters, and in some cases downgrading to
running row-at-a-time, will apply sorting to each batch of returned rows
using correspondence to primary key or other unique values in each row
which can be correlated to the input data.Performance impact is expected to be minimal as nearly all common primary
key scenarios are suitable for parameter-ordered batching to be
achieved for all backends other than SQLite, while "row-at-a-time"
mode operates with a bare minimum of Python overhead compared to the very
heavyweight approaches used in the 1.x series. For SQLite, there is no
difference in performance when "row-at-a-time" mode is used.It's anticipated that with an efficient "row-at-a-time" INSERT with
RETURNING batching capability, the "insertmanyvalues" feature can be later
be more easily generalized to third party backends that include RETURNING
support but not necessarily easy ways to guarantee a correspondence
with parameter order.
typing
-
[typing] [bug] Added typing information for recently added operators
ColumnOperators.icontains(),ColumnOperators.istartswith(),
ColumnOperators.iendswith(), and bitwise operators
ColumnOperators.bitwise_and(),ColumnOperators.bitwise_or(),
ColumnOperators.bitwise_xor(),ColumnOperators.bitwise_not(),
ColumnOperators.bitwise_lshift()
ColumnOperators.bitwise_rshift(). Pull request courtesy Martijn
Pieters.References: #9650
-
[typing] [bug] Updates to the codebase to pass typing with Mypy 1.2.0.
-
[typing] [bug] Fixed typing issue where
_orm.PropComparator.and_()expressions would
not be correctly typed inside of loader options such as
_orm.selectinload().References: #9669
postgresql
-
[postgresql] [usecase] Added
prepared_statement_name_funcconnection argument option in the
asyncpg dialect. This option allows passing a callable used to customize
the name of the prepared statement that will be created by the driver
when executing queries. Pull request courtesy Pavel Sirotkin.References: #9608
-
[postgresql] [usecase] Add missing
_postgresql.Range.intersection()method.
Pull request courtesy Yurii Karabas.References: #9509
-
[postgresql] [bug] Restored the
_postgresql.ENUM.nameparameter as optional in the
signature for_postgresql.ENUM, as this is chosen automatically
from a given pep-435Enumtype.References: #9611
-
[postgresql] [bug] Fixed issue where the comparison for
_postgresql.ENUMagainst a
plain string would cast that right-hand side type as VARCHAR, which due to
more explicit casting added to dialects such as asyncpg would produce a
PostgreSQL type mismatch error.References: #9621
-
[postgresql] [bug] Fixed issue that prevented reflection of expression based indexes
with long expressions in PostgreSQL. The expression where erroneously
truncated to the identifier length (that's 63 bytes by default).References: #9615
mssql
-
[mssql] [bug] Restored the :term:
insertmanyvaluesfeature for Microsoft SQL Server.
This feature was disabled in version 2.0.9 due to an apparent reliance
on the ordering of RETURNING that is not guaranteed. The architecture of
the "insertmanyvalues" feature has been reworked to accommodate for
specific organizations of INSERT statements and result row handling that
can guarantee the correspondence of returned rows to input records.Unknown interpreted text role "term".
oracle
- [oracle] [bug] Fixed issue where the
_sqltypes.Uuiddatatype could not be used in
an INSERT..RETURNING clause with the Oracle dialect.