]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
remove warnings for index/unique skipped due to exclude_cols
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 20 Jun 2022 15:06:34 +0000 (11:06 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 20 Jun 2022 15:07:47 +0000 (11:07 -0400)
The warnings that are emitted regarding reflection of indexes or unique
constraints, when the :paramref:`.Table.include_columns` parameter is used
to exclude columns that are then found to be part of those constraints,
have been removed. When the :paramref:`.Table.include_columns` parameter is
used it should be expected that the resulting :class:`.Table` construct
will not include constraints that rely upon omitted columns. This change
was made in response to :ticket:`8100` which repaired
:paramref:`.Table.include_columns` in conjunction with foreign key
constraints that rely upon omitted columns, where the use case became
clear that omitting such constraints should be expected.

Fixes: #8102
Change-Id: Id32f628def2d12499cd49d0b436ed345fe49dc6b

doc/build/changelog/unreleased_20/8102.rst [new file with mode: 0644]
lib/sqlalchemy/engine/reflection.py
test/engine/test_reflection.py

diff --git a/doc/build/changelog/unreleased_20/8102.rst b/doc/build/changelog/unreleased_20/8102.rst
new file mode 100644 (file)
index 0000000..1ae180f
--- /dev/null
@@ -0,0 +1,14 @@
+.. change::
+    :tags: bug, schema
+    :tickets: 8102
+
+    The warnings that are emitted regarding reflection of indexes or unique
+    constraints, when the :paramref:`.Table.include_columns` parameter is used
+    to exclude columns that are then found to be part of those constraints,
+    have been removed. When the :paramref:`.Table.include_columns` parameter is
+    used it should be expected that the resulting :class:`.Table` construct
+    will not include constraints that rely upon omitted columns. This change
+    was made in response to :ticket:`8100` which repaired
+    :paramref:`.Table.include_columns` in conjunction with foreign key
+    constraints that rely upon omitted columns, where the use case became
+    clear that omitting such constraints should be expected.
index 32c89106b71ea207987a4628cd29a2d252341c81..655a9f5c1116c59bb6d1e486ec840188dfcc4843 100644 (file)
@@ -1900,10 +1900,6 @@ class Inspector(inspection.Inspectable["Inspector"]):
 
             duplicates = index_d.get("duplicates_constraint")
             if include_columns and not set(columns).issubset(include_columns):
-                util.warn(
-                    "Omitting %s key for (%s), key covers omitted columns."
-                    % (flavor, ", ".join(columns))
-                )
                 continue
             if duplicates:
                 continue
@@ -1954,10 +1950,6 @@ class Inspector(inspection.Inspectable["Inspector"]):
             columns = const_d["column_names"]
             duplicates = const_d.get("duplicates_index")
             if include_columns and not set(columns).issubset(include_columns):
-                util.warn(
-                    "Omitting unique constraint key for (%s), "
-                    "key covers omitted columns." % ", ".join(columns)
-                )
                 continue
             if duplicates:
                 continue
index 2f6c06aceb5bf8ce0b8a706aa1b510bf0de1fec1..cf8f754f5dea0e323b45674f4ecc0d738bb41593 100644 (file)
@@ -375,7 +375,6 @@ class ReflectionTest(fixtures.TestBase, ComparesTables):
                 1,
             )
 
-    @testing.emits_warning(r".*omitted columns")
     def test_include_columns_indexes(self, connection, metadata):
         m = metadata
 
@@ -2302,7 +2301,6 @@ class IncludeColsFksTest(AssertsCompiledSQL, fixtures.TestBase):
         for c in ("a", "c", "d"):
             assert c not in foo.c
 
-    @testing.emits_warning
     @testing.combinations(True, False, argnames="resolve_fks")
     def test_include_cols_skip_fk_col(
         self, connection, tab_w_fks, resolve_fks