]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
merged r6570 from 0.5 branch, dont reflect IOT tables [ticket:1637]
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 26 Dec 2009 22:41:44 +0000 (22:41 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 26 Dec 2009 22:41:44 +0000 (22:41 +0000)
CHANGES
lib/sqlalchemy/dialects/oracle/base.py
test/dialect/test_oracle.py

diff --git a/CHANGES b/CHANGES
index 94540138180476f0998f9cbf0fcf8e200fdac483..88baa7c8f2743fc3f5b2b1fc15a205550cfde11f 100644 (file)
--- 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 
index ddcc9f4607e5ab653c2ba56b5babc60d90d1e27d..082a987ba8c5b4b09ecb70b64df88fd332707cca 100644 (file)
@@ -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]
 
index 62721c39957df0b4e613a58a224f446c488395e0..98fce16550b79c3bd8de5ad631fec707aaf697df 100644 (file)
@@ -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'