]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- use a StaticPool for componentreflectiontest to ensure
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 28 Jan 2016 22:59:48 +0000 (17:59 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 28 Jan 2016 23:10:42 +0000 (18:10 -0500)
temp tables are reflectable on the same session they were
created

lib/sqlalchemy/testing/suite/test_reflection.py

index 288a85973667bb508891e1cda82f7f22c365d21c..4a3dd902404aaa0004ba5df1c45dd5480373a6cb 100644 (file)
@@ -39,6 +39,15 @@ class ComponentReflectionTest(fixtures.TablesTest):
 
     __backend__ = True
 
+    @classmethod
+    def setup_bind(cls):
+        if config.requirements.independent_connections.enabled:
+            from sqlalchemy import pool
+            return engines.testing_engine(
+                options=dict(poolclass=pool.StaticPool))
+        else:
+            return config.db
+
     @classmethod
     def define_tables(cls, metadata):
         cls.define_reflected_tables(metadata, None)
@@ -104,7 +113,7 @@ class ComponentReflectionTest(fixtures.TablesTest):
         # temp table fixture
         if testing.against("oracle"):
             kw = {
-                'prefixes': ["GLOBAL TEMPORARY"],
+                'prefixes': ["TEMPORARY"],
                 'oracle_on_commit': 'PRESERVE ROWS'
             }
         else:
@@ -202,7 +211,7 @@ class ComponentReflectionTest(fixtures.TablesTest):
 
     @testing.requires.temp_table_names
     def test_get_temp_table_names(self):
-        insp = inspect(testing.db)
+        insp = inspect(self.bind)
         temp_table_names = insp.get_temp_table_names()
         eq_(sorted(temp_table_names), ['user_tmp'])
 
@@ -210,7 +219,7 @@ class ComponentReflectionTest(fixtures.TablesTest):
     @testing.requires.temp_table_names
     @testing.requires.temporary_views
     def test_get_temp_view_names(self):
-        insp = inspect(self.metadata.bind)
+        insp = inspect(self.bind)
         temp_table_names = insp.get_temp_view_names()
         eq_(sorted(temp_table_names), ['user_tmp_v'])
 
@@ -348,7 +357,7 @@ class ComponentReflectionTest(fixtures.TablesTest):
 
     @testing.requires.temp_table_reflection
     def test_get_temp_table_columns(self):
-        meta = MetaData(testing.db)
+        meta = MetaData(self.bind)
         user_tmp = self.tables.user_tmp
         insp = inspect(meta.bind)
         cols = insp.get_columns('user_tmp')
@@ -361,7 +370,7 @@ class ComponentReflectionTest(fixtures.TablesTest):
     @testing.requires.view_column_reflection
     @testing.requires.temporary_views
     def test_get_temp_view_columns(self):
-        insp = inspect(self.metadata.bind)
+        insp = inspect(self.bind)
         cols = insp.get_columns('user_tmp_v')
         eq_(
             [col['name'] for col in cols],
@@ -503,7 +512,7 @@ class ComponentReflectionTest(fixtures.TablesTest):
     @testing.requires.temp_table_reflection
     @testing.requires.unique_constraint_reflection
     def test_get_temp_table_unique_constraints(self):
-        insp = inspect(self.metadata.bind)
+        insp = inspect(self.bind)
         reflected = insp.get_unique_constraints('user_tmp')
         for refl in reflected:
             # Different dialects handle duplicate index and constraints
@@ -513,7 +522,7 @@ class ComponentReflectionTest(fixtures.TablesTest):
 
     @testing.requires.temp_table_reflection
     def test_get_temp_table_indexes(self):
-        insp = inspect(self.metadata.bind)
+        insp = inspect(self.bind)
         indexes = insp.get_indexes('user_tmp')
         for ind in indexes:
             ind.pop('dialect_options', None)