From: Mike Bayer Date: Mon, 28 Aug 2006 16:55:22 +0000 (+0000) Subject: - deregister Table from MetaData when autoload fails; [ticket:289] X-Git-Tag: rel_0_2_8~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e077dc627bfbc9f81cdb363a1ea1acf32f4cfe9;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - deregister Table from MetaData when autoload fails; [ticket:289] --- diff --git a/CHANGES b/CHANGES index 9ae530ace4..dd70988986 100644 --- a/CHANGES +++ b/CHANGES @@ -51,6 +51,7 @@ returns datetimes with tzinfo's if available, which can create confusion against datetimes that dont). - fix to using query.count() with distinct, **kwargs with SelectResults count() [ticket:287] +- deregister Table from MetaData when autoload fails; [ticket:289] 0.2.7 - quoting facilities set up so that database-specific quoting can be diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index bb9e534c7b..f4e89ef245 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -91,10 +91,14 @@ class TableSingleton(type): # we do it after the table is in the singleton dictionary to support # circular foreign keys if autoload: - if autoload_with: - autoload_with.reflecttable(table) - else: - metadata.engine.reflecttable(table) + try: + if autoload_with: + autoload_with.reflecttable(table) + else: + metadata.engine.reflecttable(table) + except exceptions.NoSuchTableError: + table.deregister() + raise # initialize all the column, etc. objects. done after # reflection to allow user-overrides table._init_items(*args)