From: Mike Bayer Date: Sun, 24 Jul 2016 21:37:25 +0000 (-0400) Subject: Allow Table._reset_exported to silently pass X-Git-Tag: rel_1_1_0b3~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c8643b0e98070bbf51bc38d32258526634ee67d;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Allow Table._reset_exported to silently pass Fixed bug in :class:`.Table` where the internal method ``_reset_exported()`` would corrupt the state of the object. This method is intended for selectable objects and is called by the ORM in some cases; an erroneous mapper configuration would could lead the ORM to call this on on a :class:`.Table` object. Change-Id: I63fa34ee0cdf16358bb125c556390df79758bcbc Fixes: #3755 --- diff --git a/doc/build/changelog/changelog_10.rst b/doc/build/changelog/changelog_10.rst index c977c7366d..16a38e6626 100644 --- a/doc/build/changelog/changelog_10.rst +++ b/doc/build/changelog/changelog_10.rst @@ -18,6 +18,16 @@ .. changelog:: :version: 1.0.15 + .. change:: + :tags: bug, sql + :tickets: 3755 + + Fixed bug in :class:`.Table` where the internal method + ``_reset_exported()`` would corrupt the state of the object. This + method is intended for selectable objects and is called by the ORM + in some cases; an erroneous mapper configuration would could lead the + ORM to call this on on a :class:`.Table` object. + .. change:: :tags: bug, ext :tickets: 3743 diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 858c353447..b76a6f7271 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -1230,7 +1230,6 @@ class Mapper(InspectionAttr): instrumentation.unregister_class(self.class_) def _configure_pks(self): - self.tables = sql_util.find_tables(self.mapped_table) self._pks_by_table = {} @@ -1316,7 +1315,6 @@ class Mapper(InspectionAttr): col.table not in self._cols_by_table)) def _configure_properties(self): - # Column and other ClauseElement objects which are mapped self.columns = self.c = util.OrderedProperties() diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index ee139827a8..55d0b74e61 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -598,6 +598,9 @@ class Table(DialectKWArgs, SchemaItem, TableClause): def _init_collections(self): pass + def _reset_exported(self): + pass + @property def _autoincrement_column(self): return self.primary_key._autoincrement_column diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py index 92d35e6e53..846e705898 100644 --- a/test/sql/test_metadata.py +++ b/test/sql/test_metadata.py @@ -1231,6 +1231,21 @@ class TableTest(fixtures.TestBase, AssertsCompiledSQL): t.info['bar'] = 'zip' assert t.info['bar'] == 'zip' + def test_reset_exported_passes(self): + + m = MetaData() + + t = Table('t', m, Column('foo', Integer)) + eq_( + list(t.c), [t.c.foo] + ) + + t._reset_exported() + + eq_( + list(t.c), [t.c.foo] + ) + def test_foreign_key_constraints_collection(self): metadata = MetaData() t1 = Table('foo', metadata, Column('a', Integer))