Fixed ORM regression where ad-hoc label names generated for hybrid
properties and potentially other similar types of ORM-enabled expressions
would usually be propagated outwards through subqueries, allowing the name
to be retained in the final keys of the result set even when selecting from
subqueries. Additional state is now tracked in this case that isn't lost
when a hybrid is selected out of a Core select / subquery.
as we have removed things like column.label() from
ORM, since we now have to export the cols with the same names
as what we will render, experiment with giving a greater role
to the _proxy_key annotation so that a desired name can be
carried through more transarently.
Fixes: #6718
Change-Id: Icb313244c13ea1a8f58d3e05d07aa3e1039e15bf
Fixed regression caused in 1.4.19 due to #6503 and related involving
:meth:`_orm.Query.with_entities` where the new structure used would be
inappropriately transferred to an enclosing :class:`_orm.Query` when making
use of set operations such as :meth:`_orm.Query.union`, causing the JOIN
instructions within to be applied to the outside query as well.
Fixes: #6698
Change-Id: Ia9f294215ebc01330d142a0a3e5be9d02be9380f
Fixed regression where the special dotted-schema name handling for the SQL
Server dialect would not function correctly if the dotted schema name were
used within the ``schema_translate_map`` feature.
Fixes: #6697
Change-Id: Idb610755cbf8122e71223d5dd0a17fcb61b1b98d
Fixed issue in :meth:`_postgresql.Insert.on_conflict_do_nothing` and
:meth:`_postgresql.Insert.on_conflict_do_update` where the name of a unique
constraint passed as the ``constraint`` parameter would not be properly
quoted if it contained characters which required quoting.
Fixes: #6696
Change-Id: I4ffca9b8c72cef4ed39e2de96831ccc11a620422
Use the term "collection" instead of "many" as the
"side" where "uselist=False" goes. Clarify that
one-to-one is in many ways a convention.
Fixes: #6692
Change-Id: I2bc7b24c9f57747306fdcf4b6376ac7eb3bff78b
Adjusted the check in the mapper for a callable object that is used as a
``@validates`` validator function or a ``@reconstructor`` reconstruction
function, to check for "callable" more liberally such as to accommodate
objects based on fundamental attributes like ``__func__`` and
``__call___``, rather than testing for ``MethodType`` / ``FunctionType``,
allowing things like cython functions to work properly. Pull request
courtesy Miłosz Stypiński.
Fixes: #6538Closes: #6539
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6539
Pull-request-sha: ed1d7fe5c9
Change-Id: I8350558bc9a9ba58f43e48e12ce25a0b30e4d767
Fixed issue where passing ``None`` for the value of
:paramref:`_schema.Table.prefixes` would not store an empty list, but
rather the constant ``None``, which may be unexpected by third party
dialects. The issue is revealed by a usage in recent versions of Alembic
that are passing ``None`` for this value. Pull request courtesy Kai
Mueller.
Fixes: #6685Closes: #6672
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6672
Pull-request-sha: b79aca0ee4
Change-Id: I758641c6fbde6f2607d074fecea7efa6728aeea0
Made a small adjustment in the table reflection feature of the MySQL
dialect to accommodate for alternate MySQL-oriented databases such as TiDB
which include their own "comment" directives at the end of a constraint
directive within "CREATE TABLE" where the format doesn't have the
additional space character after the comment, in this case the TiDB
"clustered index" feature. Pull request courtesy Daniël van Eeden.
Fixes: #6659Closes: #6660
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6660
Pull-request-sha: 98791a441b
Change-Id: I20d206e0cdb809e4c6997b87159edf41249f7cd9
Fixed regression in ORM regarding an internal reconstitution step for the
func:`_orm.with_polymorphic` construct, when the user-facing object is
garbage collected as the query is processed. The reconstitution was not
ensuring the sub-entities for the "polymorphic" case were handled, leading
to an ``AttributeError``.
Fixes: #6680
Change-Id: Id35b16d0f2aadb50b5a7385a21fa81b9d8a8325f
Adjusted :meth:`_orm.Query.union` and similar set operations to be
correctly compatible with the new capabilities just added in
🎫`6661`, with SQLAlchemy 1.4.19, such that the SELECT statements
rendered as elements of the UNION or other set operation will include
directly mapped columns that are mapped as deferred; this both fixes a
regression involving unions with multiple levels of nesting that would
produce a column mismatch, and also allows the :func:`_orm.undefer` option
to be used at the top level of such a :class:`_orm.Query` without having to
apply the option to each of the elements within the UNION.
Fixes: #6678
Change-Id: Iba97ce7fd8a965499853256fd2eb7f61512db60f
We haven't had any real cases of the PG "cant drop tables"
condition since this error was first introduced; instead we
seem to get it for a non-critical query during pool reconnect
tests, and I have not been able to isolate what is causing it.
Therefore turn the error into a new class of warning that can
emit within the test suite without failing the test, so that
if we do get a real PG drop timeout, the warning will be there
to show us what the query was in which it was stuck.
Change-Id: I1a9b3c4f7a25b7b9c1af722a721fc44ad5575b0f
Fixed regression in :mod:`sqlalchemy.ext.automap` extension such that the
use case of creating an explicit mapped class to a table that is also the
:paramref:`_orm.relationship.secondary` element of a
:func:`_orm.relationship` that automap will be generating would emit the
"overlaps" warnings introduced in 1.4 and discussed at :ref:`error_qzyx`.
While generating this case from automap is still subject to the same
caveats that the "overlaps" warning refers towards, as automap is intended
for more ad-hoc use cases, the condition which produces the warning is
disabled when a many-to-many relationship with this particular pattern is
generated.
Fixes: #6679
Change-Id: Ib3a53982b076ed4999b0d3235f84008b9e2f1cce
Add a impl parameter to :class:`_types.PickleType` constructor, allowing
any arbitary type to be used in place of the default implementation of
:class:`_types.LargeBinary`. Pull request courtesy jason3gb.
Fixes: #6646Closes: #6657
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6657
Pull-request-sha: e49bcd368d
Change-Id: Ib79f3b0ebbc94393f673f5a5ba6558260083d0cf
Fixed an issue in the C extension for the :class:`_result.Row` class which
could lead to a memory leak in the unlikely case of a :class:`_result.Row`
object which referred to an ORM object that then was mutated to refer back
to the ``Row`` itself, creating a cycle. The Python C APIs for tracking GC
cycles has been added to the native :class:`_result.Row` implementation to
accommodate for this case.
Fixes: #5348
Change-Id: I3ac32012f29fbb59f8921cf2a124fa3a7ac5f0d1
Fixed the class hierarchy for the :class:`_schema.Sequence` and the more
general :class:`_schema.DefaultGenerator` base, as these are "executable"
as statements they need to include :class:`_sql.Executable` in their
hierarchy, not just :class:`_roles.StatementRole` as was applied
arbitrarily to :class:`_schema.Sequence` previously. The fix allows
:class:`_schema.Sequence` to work in all ``.execute()`` methods including
with :meth:`_orm.Session.execute` which was not working in the case that a
``do_orm_execute()`` handler was also established.
Fixes: #6668
Change-Id: I0d192258c7cbd1bce2552f9e748e8fdd680dc45f
Fixed old issue where a :func:`_sql.select()` made against the token "*",
which then yielded exactly one column, would fail to correctly organize the
``cursor.description`` column name into the keys of the result object.
Fixes: #6665
Change-Id: Ie8c00f62998972ad4a19a750d2642d00fde006f6
this is the option one might want to use to undefer
a deferred column into a subquery; the message here explains
that is not applicable in 1.4.
Change-Id: Iea6c48f69c540e11ff5c3f6c8c56cc5cf2bf257b
Fixed issue where the ``INTERVAL`` datatype on PostgreSQL and Oracle would
produce an ``AttributeError`` when used in the context of a comparison
operation against a ``timedelta()`` object. Pull request courtesy
MajorDallas.
Fixes: #6649Closes: #6650
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6650
Pull-request-sha: dd217a975e
Change-Id: I773caf2673294fdb3c92b42895ad714e944d1bf8
Refined the behavior of ORM subquery rendering with regards to deferred
columns and column properties to be more compatible with that of 1.3 while
also providing for 1.4's newer features. As a subquery in 1.4 does not make
use of loader options, including :func:`_orm.deferred`, a subquery that is
against an ORM entity with deferred attributes will now render those
deferred attributes that refer directly to mapped table columns, as these
are needed in the outer SELECT if that outer SELECT makes use of these
columns; however a deferred attribute that refers to a composed SQL
expression as we normally do with :func:`_orm.column_property` will not be
part of the subquery, as these can be selected explicitly if needed in the
subquery. If the entity is being SELECTed from this subquery, the column
expression can still render on "the outside" in terms of the derived
subquery columns. This produces essentially the same behavior as when
working with 1.3. However in this case the fix has to also make sure that
the ``.selected_columns`` collection of an ORM-enabled :func:`_sql.select`
also follows these rules, which in particular allows recursive CTEs to
render correctly in this scenario, which were previously failing to render
correctly due to this issue.
As part of this change the _exported_columns_iterator() method has been
removed and logic simplified to use ._all_selected_columns from any
SelectBase object where _exported_columns_iterator() was used before.
Additionally sets up UpdateBase to include ReturnsRows in its hierarchy;
the literal point of ReturnsRows was to be a common base for UpdateBase
and SelectBase so it was kind of weird it wasn't there.
Fixes: #6661
Fixed issue in CTE constructs mostly relevant to ORM use cases where a
recursive CTE against "anonymous" labels such as those seen in ORM
``column_property()`` mappings would render in the
``WITH RECURSIVE xyz(...)`` section as their raw internal label and not a
cleanly anonymized name.
Fixes: #6663
Change-Id: I26219d4d8e6c0915b641426e9885540f74fae4d2
Made improvements to the server version regexp used by the pymssql
dialect to prevent a regexp overflow in case of an invalid version
string.
Fixes: #5557
Change-Id: Ia3e95a9f11f5a121d84474c97f6b122cf8d9c9cf