diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-12-26 22:34:28 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-12-26 22:34:28 +0000 |
commit | 58cef5b1321f94971d3c3ad446b384cf38d734ab (patch) | |
tree | 98bfc719ea4553ff1b28fb14be7d34b52ab21984 | |
parent | f9487913f860049a7c7801793f5e88224a6b3748 (diff) | |
download | sqlalchemy-58cef5b1321f94971d3c3ad446b384cf38d734ab.tar.gz |
- 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]
-rw-r--r-- | CHANGES | 9 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/oracle.py | 7 | ||||
-rw-r--r-- | test/dialect/test_oracle.py | 29 |
3 files changed, 42 insertions, 3 deletions
@@ -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 852cab448..86c19aca4 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 d9d64806e..de04beb39 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' |