From ec04620f1fe609881ed2ad4a3d5b2fe313f4efa4 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 3 Jun 2013 16:40:59 -0400 Subject: 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. [ticket:2728] --- lib/sqlalchemy/schema.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/sqlalchemy/schema.py') diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index 3a74cbd59..3d59e8291 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -2711,13 +2711,22 @@ class MetaData(SchemaItem): bind.dialect.get_view_names(conn, schema) ) + 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: -- cgit v1.2.1