"tables" collection passed to before/after create events for metadata no longer a list of tables

Issue #3391 resolved
Mike Bayer repo owner created an issue

again due to #3282, the format of the "tables" collection has changed and we aren't converting it back to the previous format nor did we put anything in migration about it. While the documentation doesn't claim a format here, the collection is still key enough that we should probably keep it as it was:

diff --git a/test/engine/test_ddlevents.py b/test/engine/test_ddlevents.py
index 1830017..3416b0e 100644
--- a/test/engine/test_ddlevents.py
+++ b/test/engine/test_ddlevents.py
@@ -19,29 +19,41 @@ class DDLEventTest(fixtures.TestBase):
             self.state = None
             self.schema_item = schema_item
             self.bind = bind
+            if isinstance(schema_item, MetaData):
+                self.tables = set(schema_item.tables.values())
+            else:
+                self.tables = None

         def before_create(self, schema_item, bind, **kw):
             assert self.state is None
             assert schema_item is self.schema_item
             assert bind is self.bind
+            if self.tables:
+                eq_(self.tables, set(kw['tables']))
             self.state = 'before-create'

         def after_create(self, schema_item, bind, **kw):
             assert self.state in ('before-create', 'skipped')
             assert schema_item is self.schema_item
             assert bind is self.bind
+            if self.tables:
+                eq_(self.tables, set(kw['tables']))
             self.state = 'after-create'

         def before_drop(self, schema_item, bind, **kw):
             assert self.state is None
             assert schema_item is self.schema_item
             assert bind is self.bind
+            if self.tables:
+                eq_(self.tables, set(kw['tables']))
             self.state = 'before-drop'

         def after_drop(self, schema_item, bind, **kw):
             assert self.state in ('before-drop', 'skipped')
             assert schema_item is self.schema_item
             assert bind is self.bind
+            if self.tables:
+                eq_(self.tables, set(kw['tables']))
             self.state = 'after-drop'

     def setup(self):

Comments (1)

  1. Mike Bayer reporter
    • Fixed regression due to 🎫3282 where the tables collection passed as a keyword argument to the :meth:.DDLEvents.before_create, :meth:.DDLEvents.after_create, :meth:.DDLEvents.before_drop, and :meth:.DDLEvents.after_drop events would no longer be a list of tables, but instead a list of tuples which contained a second entry with foreign keys to be added or dropped. As the tables collection, while documented as not necessarily stable, has come to be relied upon, this change is considered a regression. Additionally, in some cases for "drop", this collection would be an iterator that would cause the operation to fail if prematurely iterated. The collection is now a list of table objects in all cases and test coverage for the format of this collection is now added. fixes #3391

    → <<cset e25ef01fbb70>>

  2. Log in to comment