.. changelog::
:version: 0.8.2
+ .. change::
+ :tags: bug, sql, reflection
+ :tickets: 2728
+
+ Fixed bug whereby using :meth:`.MetaData.reflect` across a remote
+ schema as well as a local schema could produce wrong results
+ in the case where both schemas had a table of the same name.
+
.. change::
:tags: bug, sql
:tickets: 2726
bind.dialect.get_view_names(conn, schema)
)
- current = set(self.tables.iterkeys())
+ if schema is not None:
+ available_w_schema = util.OrderedSet(["%s.%s" % (schema, name)
+ for name in available])
+ else:
+ available_w_schema = available
+
+ current = set(self.tables)
if only is None:
- load = [name for name in available if name not in current]
+ load = [name for name, schname in
+ zip(available, available_w_schema)
+ if schname not in current]
elif util.callable(only):
- load = [name for name in available
- if name not in current and only(name, self)]
+ load = [name for name, schname in
+ zip(available, available_w_schema)
+ if schname not in current and only(name, self)]
else:
missing = [name for name in only if name not in available]
if missing:
'test_schema.email_addresses'])
)
+ @testing.requires.schemas
+ @testing.provide_metadata
+ def test_reflect_all_schemas_default_overlap(self):
+ t1 = Table('t', self.metadata,
+ Column('id', Integer, primary_key=True))
+
+ t2 = Table('t', self.metadata,
+ Column('id1', sa.ForeignKey('t.id')),
+ schema="test_schema"
+ )
+
+ self.metadata.create_all()
+ m2 = MetaData()
+ m2.reflect(testing.db, schema="test_schema")
+
+ m3 = MetaData()
+ m3.reflect(testing.db)
+ m3.reflect(testing.db, schema="test_schema")
+
+ eq_(
+ set((t.name, t.schema) for t in m2.tables.values()),
+ set((t.name, t.schema) for t in m3.tables.values())
+ )
+