1.4.12
Released: April 29, 2021
orm
-
[orm] [bug] Fixed issue in
_orm.Session.bulk_save_objects()
when used with persistent
objects which would fail to track the primary key of mappings where the
column name of the primary key were different than the attribute name.This change is also backported to: 1.3.25
References: #6392
-
[orm] [bug] [caching] [regression] Fixed critical regression where bound parameter tracking as used in the SQL
caching system could fail to track all parameters for the case where the
same SQL expression containing a parameter were used in an ORM-related
query using a feature such as class inheritance, which was then embedded in
an enclosing expression which would make use of that same expression
multiple times, such as a UNION. The ORM would individually copy the
individual SELECT statements as part of compilation with class inheritance,
which then embedded in the enclosing statement would fail to accommodate
for all parameters. The logic that tracks this condition has been adjusted
to work for multiple copies of a parameter.References: #6391
-
[orm] [bug] Fixed two distinct issues mostly affecting
_hybrid.hybrid_property
, which would come into play under common
mis-configuration scenarios that were silently ignored in 1.3, and now
failed in 1.4, where the "expression" implementation would return a non
_sql.ClauseElement
such as a boolean value. For both issues, 1.3's
behavior was to silently ignore the mis-configuration and ultimately
attempt to interpret the value as a SQL expression, which would lead to an
incorrect query.- Fixed issue regarding interaction of the attribute system with hybrid_property, where if the `__clause_element__()` method of the attribute returned a non-`_sql.ClauseElement` object, an internal `AttributeError` would lead the attribute to return the `expression` function on the hybrid_property itself, as the attribute error was against the name `.expression` which would invoke the `__getattr__()` method as a fallback. This now raises explicitly. In 1.3 the non-`_sql.ClauseElement` was returned directly. - Fixed issue in SQL argument coercions system where passing the wrong kind of object to methods that expect column expressions would fail if the object were altogether not a SQLAlchemy object, such as a Python function, in cases where the object were not just coerced into a bound value. Again 1.3 did not have a comprehensive argument coercion system so this case would also pass silently.
References: #6350
-
[orm] [bug] Fixed issue where using a
_sql.Select
as a subquery in an ORM
context would modify the_sql.Select
in place to disable
eagerloads on that object, which would then cause that same
_sql.Select
to not eagerload if it were then re-used in a
top-level execution context.References: #6378
-
[orm] [bug] [regression] Fixed issue where the new
autobegin <session_autobegin>
behavior
failed to "autobegin" in the case where an existing persistent object has
an attribute change, which would then impact the behavior of
_orm.Session.rollback()
in that no snapshot was created to be rolled
back. The "attribute modify" mechanics have been updated to ensure
"autobegin", which does not perform any database work, does occur when
persistent attributes change in the same manner as when
_orm.Session.add()
is called. This is a regression as in 1.3, the
rollback() method always had a transaction to roll back and would expire
every time. -
[orm] [bug] [regression] Fixed regression in ORM where using hybrid property to indicate an
expression from a different entity would confuse the column-labeling logic
in the ORM and attempt to derive the name of the hybrid from that other
class, leading to an attribute error. The owning class of the hybrid
attribute is now tracked along with the name.References: #6386
-
[orm] [bug] [regression] Fixed regression in hybrid_property where a hybrid against a SQL function
would generate anAttributeError
when attempting to generate an entry
for the.c
collection of a subquery in some cases; among other things
this would impact its use in cases like that ofQuery.count()
.References: #6401
-
[orm] [bug] [dataclasses] Adjusted the declarative scan for dataclasses so that the inheritance
behavior of_orm.declared_attr()
established on a mixin, when using
the new form of having it inside of adataclasses.field()
construct and
not actually a descriptor attribute on the class, correctly accommodates
the case when the target class to be mapped is a subclass of an existing
mapped class which has already mapped that_orm.declared_attr()
, and
therefore should not be re-applied to this class.References: #6346
-
[orm] [bug] Fixed an issue with the (deprecated in 1.4)
_schema.ForeignKeyConstraint.copy()
method that caused an error when
invoked with theschema
argument.References: #6353
engine
-
[engine] [bug] Fixed issue where usage of an explicit
Sequence
would produce
inconsistent "inline" behavior for anInsert
construct that
includes multiple values phrases; the first seq would be inline but
subsequent ones would be "pre-execute", leading to inconsistent sequence
ordering. The sequence expressions are now fully inline.References: #6361
sql
-
[sql] [bug] Revised the "EMPTY IN" expression to no longer rely upon using a subquery,
as this was causing some compatibility and performance problems. The new
approach for selected databases takes advantage of using a NULL-returning
IN expression combined with the usual "1 != 1" or "1 = 1" expression
appended by AND or OR. The expression is now the default for all backends
other than SQLite, which still had some compatibility issues regarding
tuple "IN" for older SQLite versions.Third party dialects can still override how the "empty set" expression
renders by implementing a new compiler method
def visit_empty_set_op_expr(self, type_, expand_op)
, which takes
precedence over the existing
def visit_empty_set_expr(self, element_types)
which remains in place.References: [#6258 6397](http://www.sqlalchemy.org/trac/ticket/6258 6397)
-
[sql] [bug] [regression] Fixed regression where usage of the
_sql.text()
construct inside the
columns clause of a_sql.Select
construct, which is better handled
by using a_sql.literal_column()
construct, would nonetheless prevent
constructs like_sql.union()
from working correctly. Other use cases,
such as constructing subuqeries, continue to work the same as in prior
versions where the_sql.text()
construct is silently omitted from the
collection of exported columns. Also repairs similar use within the
ORM.References: #6343
-
[sql] [bug] [regression] Fixed regression involving legacy methods such as
_sql.Select.append_column()
where internal assertions would fail.References: #6261
-
[sql] [bug] [regression] Fixed regression caused by #5395 where tuning back the check for
sequences in_sql.select()
now caused failures when doing 2.0-style
querying with a mapped class that also happens to have an__iter__()
method. Tuned the check some more to accommodate this as well as some other
interesting__iter__()
scenarios.References: #6300
schema
-
[schema] [bug] [mariadb] [mysql] [oracle] [postgresql] Ensure that the MySQL and MariaDB dialect ignore the
_sql.Identity
construct while rendering theAUTO_INCREMENT
keyword in a create table.The Oracle and PostgreSQL compiler was updated to not render
_sql.Identity
if the database version does not support it
(Oracle < 12 and PostgreSQL < 10). Previously it was rendered regardless
of the database version.References: #6338
postgresql
-
[postgresql] [bug] Fixed very old issue where the
_types.Enum
datatype would not
inherit the_schema.MetaData.schema
parameter of a
_schema.MetaData
object when that object were passed to the
_types.Enum
using_types.Enum.metadata
.References: #6373
sqlite
-
[sqlite] [usecase] Default to using
SingletonThreadPool
for in-memory SQLite databases
created using URI filenames. Previously the default pool used was the
NullPool
that precented sharing the same database between multiple
engines.References: #6379
mssql
-
[mssql] [bug] [schema] Add
_types.TypeEngine.as_generic()
support for
sqlalchemy.dialects.mysql.BIT
columns, mapping
them to_sql.sqltypes.Boolean
.References: #6345
-
[mssql] [bug] [regression] Fixed regression caused by #6306 which added support for
DateTime(timezone=True)
, where the previous behavior of the pyodbc
driver of implicitly dropping the tzinfo from a timezone-aware date when
INSERTing into a timezone-naive DATETIME column were lost, leading to a SQL
Server error when inserting timezone-aware datetime objects into
timezone-native database columns.References: #6366