]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Allow Table._reset_exported to silently pass
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 24 Jul 2016 21:37:25 +0000 (17:37 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 25 Jul 2016 03:17:11 +0000 (23:17 -0400)
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
doc/build/changelog/changelog_10.rst
lib/sqlalchemy/orm/mapper.py
lib/sqlalchemy/sql/schema.py
test/sql/test_metadata.py

index c977c7366d0e67d9d28375cc5d8f179406717d60..16a38e662632fb4ce95b1271a614d7bddad47366 100644 (file)
 .. 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
index 858c35344738d7a889d56fc05618e5ef35acb1e0..b76a6f7271688179299443aff052b034b3f67036 100644 (file)
@@ -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()
 
index ee139827a81e3dfe37e56d3f3e1a3ed2b0f971f8..55d0b74e61bbc4eb5ae50f5d05f9d2c4dc763f30 100644 (file)
@@ -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
index 92d35e6e5346a33982b5c9077af3394d96e889d9..846e7058989446a9459bf2d87b342a15ba6ecf47 100644 (file)
@@ -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))