]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed an assertion that would raise somewhat inappropriately
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 24 Dec 2015 03:59:44 +0000 (22:59 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 24 Dec 2015 03:59:44 +0000 (22:59 -0500)
if a :class:`.Index` were associated with a :class:`.Column` that
is associated with a lower-case-t :class:`.TableClause`; the
association should be ignored for the purposes of associating
the index with a :class:`.Table`.
fixes #3616

doc/build/changelog/changelog_11.rst
lib/sqlalchemy/sql/schema.py
test/sql/test_metadata.py

index 0d9f997f9913bfa3d52a09bf07b55c629ffde894..83a57ba7cfa701d98fe99a6254869b4610be1e60 100644 (file)
 .. changelog::
     :version: 1.1.0b1
 
+    .. change::
+        :tags: bug, sql
+        :tickets: 3616
+
+        Fixed an assertion that would raise somewhat inappropriately
+        if a :class:`.Index` were associated with a :class:`.Column` that
+        is associated with a lower-case-t :class:`.TableClause`; the
+        association should be ignored for the purposes of associating
+        the index with a :class:`.Table`.
+
     .. change::
         :tags: bug, orm
         :tickets: 3601
index 42dbe72b2d5bd50670a4ae00c4a59b59db0c8fa5..b244d746c3d19b549e7f641fa49b34756f8fe470 100644 (file)
@@ -2498,9 +2498,13 @@ class ColumnCollectionMixin(object):
             has_string_cols = set(self._pending_colargs).difference(col_objs)
             if not has_string_cols:
                 def _col_attached(column, table):
-                    cols_wo_table.discard(column)
-                    if not cols_wo_table:
-                        self._check_attach(evt=True)
+                    # this isinstance() corresponds with the
+                    # isinstance() above; only want to count Table-bound
+                    # columns
+                    if isinstance(table, Table):
+                        cols_wo_table.discard(column)
+                        if not cols_wo_table:
+                            self._check_attach(evt=True)
                 self._cols_wo_table = cols_wo_table
                 for col in cols_wo_table:
                     col._on_table_attach(_col_attached)
index d4039a5fecdc5b1ade8f8dfaaed81971a622698d..bbc318421e2957fe153ada74dd43c0c3c594546c 100644 (file)
@@ -2068,6 +2068,13 @@ class IndexTest(fixtures.TestBase):
             t.append_constraint, idx
         )
 
+    def test_column_associated_w_lowercase_table(self):
+        from sqlalchemy import table
+        c = Column('x', Integer)
+        table('foo', c)
+        idx = Index('q', c)
+        is_(idx.table, None)  # lower-case-T table doesn't have indexes
+
 
 class ConstraintTest(fixtures.TestBase):