]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Warn when sorted_tables is not actually sorting
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 7 May 2020 21:13:35 +0000 (17:13 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 7 May 2020 23:56:32 +0000 (19:56 -0400)
commit8782469b789585d3f0c3a642f0bb9519816f6b11
tree4d4c0e033cd235ec57935c6d037756d21f43ff8f
parent9821bddfcb3c94cea13b7f19bcb27845b0dc1ed8
Warn when sorted_tables is not actually sorting

A warning is emitted when making use of the :attr:`.MetaData.sorted_tables`
attribute as well as the :func:`_schema.sort_tables` function, and the
given tables cannot be correctly sorted due to a cyclic dependency between
foreign key constraints. In this case, the functions will no longer sort
the involved tables by foreign key, and a warning will be emitted. Other
tables that are not part of the cycle will still be returned in dependency
order. Previously, the sorted_table routines would return a collection that
would unconditionally omit all foreign keys when a cycle was detected, and
no warning was emitted.

Fixes: #5316
Change-Id: I14f72ccf39cb568bc77e8da16d0685718b2b9960
doc/build/changelog/unreleased_13/5316.rst [new file with mode: 0644]
lib/sqlalchemy/sql/ddl.py
lib/sqlalchemy/sql/schema.py
lib/sqlalchemy/testing/fixtures.py
test/sql/test_metadata.py