From: Mike Bayer Date: Sat, 26 Dec 2009 22:34:28 +0000 (+0000) Subject: - The "table_names" dialect function, used by MetaData X-Git-Tag: rel_0_5_7~2 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=58cef5b1321f94971d3c3ad446b384cf38d734ab;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - The "table_names" dialect function, used by MetaData .reflect(), omits Oracle "index overflow tables", a system table generated by Oracle when "index only tables" with overflow are used. These tables aren't accessible via SQL and can't be reflected. [ticket:1637] --- diff --git a/CHANGES b/CHANGES index 86f3de0055..700d4b088a 100644 --- a/CHANGES +++ b/CHANGES @@ -131,7 +131,14 @@ CHANGES - Fixed erroneous reference to "owner" attribute in Informix dialect when reflecting tables. [ticket:1645] - + +- oracle + - The "table_names" dialect function, used by MetaData + .reflect(), omits "index overflow tables", a system + table generated by Oracle when "index only tables" + with overflow are used. These tables aren't accessible + via SQL and can't be reflected. [ticket:1637] + - ext - A column can be added to a joined-table declarative superclass after the class has been constructed diff --git a/lib/sqlalchemy/databases/oracle.py b/lib/sqlalchemy/databases/oracle.py index 852cab448e..86c19aca42 100644 --- a/lib/sqlalchemy/databases/oracle.py +++ b/lib/sqlalchemy/databases/oracle.py @@ -516,10 +516,13 @@ class OracleDialect(default.DefaultDialect): def table_names(self, connection, schema): # note that table_names() isnt loading DBLINKed or synonym'ed tables if schema is None: - s = "select table_name from all_tables where nvl(tablespace_name, 'no tablespace') NOT IN ('SYSTEM', 'SYSAUX')" + s = "select table_name from all_tables where nvl(tablespace_name, 'no tablespace') "\ + "NOT IN ('SYSTEM', 'SYSAUX') AND IOT_NAME IS NULL" cursor = connection.execute(s) else: - s = "select table_name from all_tables where nvl(tablespace_name, 'no tablespace') NOT IN ('SYSTEM','SYSAUX') AND OWNER = :owner" + s = "select table_name from all_tables where nvl(tablespace_name, 'no tablespace') "\ + "NOT IN ('SYSTEM','SYSAUX') AND OWNER = :owner "\ + "AND IOT_NAME IS NULL" cursor = connection.execute(s, {'owner': self._denormalize_name(schema)}) return [self._normalize_name(row[0]) for row in cursor] diff --git a/test/dialect/test_oracle.py b/test/dialect/test_oracle.py index d9d64806e8..de04beb394 100644 --- a/test/dialect/test_oracle.py +++ b/test/dialect/test_oracle.py @@ -396,6 +396,35 @@ class TypesTest(TestBase, AssertsCompiledSQL): eq_(row['bindata'].read(), 'this is binary') finally: t.drop(engine) + +class DontReflectIOTTest(TestBase): + """test that index overflow tables aren't included in table_names.""" + + def setup(self): + testing.db.execute(""" + CREATE TABLE admin_docindex( + token char(20), + doc_id NUMBER, + token_frequency NUMBER, + token_offsets VARCHAR2(2000), + CONSTRAINT pk_admin_docindex PRIMARY KEY (token, doc_id)) + ORGANIZATION INDEX + TABLESPACE users + PCTTHRESHOLD 20 + OVERFLOW TABLESPACE users + """) + + def teardown(self): + testing.db.execute("drop table admin_docindex") + + def test_reflect_all(self): + m = MetaData(testing.db) + m.reflect() + eq_( + set(t.name for t in m.tables.values()), + set(['admin_docindex']) + ) + class BufferedColumnTest(TestBase, AssertsCompiledSQL): __only_on__ = 'oracle'