From: Mike Bayer Date: Sat, 26 Dec 2009 22:41:44 +0000 (+0000) Subject: merged r6570 from 0.5 branch, dont reflect IOT tables [ticket:1637] X-Git-Tag: rel_0_6beta1~117 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bc5ad4e8afcdda269e0ec0d1c2fc40da13d2b999;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git merged r6570 from 0.5 branch, dont reflect IOT tables [ticket:1637] --- diff --git a/CHANGES b/CHANGES index 9454013818..88baa7c8f2 100644 --- a/CHANGES +++ b/CHANGES @@ -898,6 +898,13 @@ CHANGES Trusted_Connection when constructing pyodbc connect arguments [ticket:1561] +- 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/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py index ddcc9f4607..082a987ba8 100644 --- a/lib/sqlalchemy/dialects/oracle/base.py +++ b/lib/sqlalchemy/dialects/oracle/base.py @@ -551,12 +551,14 @@ class OracleDialect(default.DefaultDialect): if schema is None: cursor = connection.execute( "SELECT table_name FROM all_tables " - "WHERE nvl(tablespace_name, 'no tablespace') NOT IN ('SYSTEM', 'SYSAUX')") + "WHERE nvl(tablespace_name, 'no tablespace') NOT IN ('SYSTEM', 'SYSAUX') " + "AND IOT_NAME IS NULL") else: s = sql.text( "SELECT table_name FROM all_tables " "WHERE nvl(tablespace_name, 'no tablespace') NOT IN ('SYSTEM', 'SYSAUX') " - "AND OWNER = :owner") + "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 62721c3995..98fce16550 100644 --- a/test/dialect/test_oracle.py +++ b/test/dialect/test_oracle.py @@ -527,6 +527,34 @@ class TypesTest(TestBase, AssertsCompiledSQL): 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'