]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
test fixes for oracle 18c
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 18 Dec 2020 15:46:20 +0000 (10:46 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 18 Dec 2020 16:21:18 +0000 (11:21 -0500)
Change-Id: I4968aa3bde3c4d11d7fe84f18b4a846ba357d16a

lib/sqlalchemy/dialects/oracle/base.py
lib/sqlalchemy/dialects/oracle/provision.py
lib/sqlalchemy/testing/fixtures.py
lib/sqlalchemy/testing/plugin/plugin_base.py
lib/sqlalchemy/testing/provision.py
test/dialect/oracle/test_dialect.py

index 3ead97faf66a789d1db9496829753ad1f0100a60..316dd547e389ef281e4844cf0d0d58c81e2c76d0 100644 (file)
@@ -1864,11 +1864,13 @@ class OracleDialect(default.DefaultDialect):
                 col.default_on_null,
                 (
                     SELECT id.generation_type || ',' || id.IDENTITY_OPTIONS
-                    FROM ALL_TAB_IDENTITY_COLS id
+                    FROM ALL_TAB_IDENTITY_COLS%(dblink)s id
                     WHERE col.table_name = id.table_name
                     AND col.column_name = id.column_name
                     AND col.owner = id.owner
-                ) AS identity_options"""
+                ) AS identity_options""" % {
+                "dblink": dblink
+            }
         else:
             identity_cols = "NULL as default_on_null, NULL as identity_options"
 
index aadc2c5a999d6021c89afd8f5cf4be06529c1d96..d51131c0b6169b8bdc74089843faa4cea7153d55 100644 (file)
@@ -8,6 +8,7 @@ from ...testing.provision import follower_url_from_main
 from ...testing.provision import log
 from ...testing.provision import run_reap_dbs
 from ...testing.provision import set_default_schema_on_connection
+from ...testing.provision import stop_test_class
 from ...testing.provision import temp_table_keyword_args
 from ...testing.provision import update_db_opts
 
@@ -61,6 +62,18 @@ def _oracle_update_db_opts(db_url, db_opts):
     pass
 
 
+@stop_test_class.for_db("oracle")
+def stop_test_class(config, db, cls):
+    """run magic command to get rid of identity sequences
+
+    # https://floo.bar/2019/11/29/drop-the-underlying-sequence-of-an-identity-column/
+
+    """
+
+    with db.begin() as conn:
+        conn.exec_driver_sql("purge recyclebin")
+
+
 @run_reap_dbs.for_db("oracle")
 def _reap_oracle_dbs(url, idents):
     log.info("db reaper connecting to %r", url)
index 54b1cbb465b6fa5c71139a585e271fddb42de97d..0ede25176a4c7bf439ec488b28378e36e61fd40e 100644 (file)
@@ -206,7 +206,11 @@ class TablesTest(TestBase):
             drop_all_tables(self.metadata, self.bind)
 
         # no need to run deletes if tables are recreated on setup
-        if self.run_define_tables != "each" and self.run_deletes == "each":
+        if (
+            self.run_define_tables != "each"
+            and self.run_create_tables != "each"
+            and self.run_deletes == "each"
+        ):
             with self.bind.begin() as conn:
                 for table in reversed(
                     [
index 34e3c57603120bc5b6380d0b73aa1f9d8f473000..b390158527e0e0c3fd3241422bf7edefc57d5ea6 100644 (file)
@@ -45,6 +45,7 @@ engines = None
 exclusions = None
 warnings = None
 profiling = None
+provision = None
 assertions = None
 requirements = None
 config = None
@@ -283,12 +284,12 @@ def post_begin():
         fn(options, file_config)
 
     # late imports, has to happen after config.
-    global util, fixtures, engines, exclusions, assertions
+    global util, fixtures, engines, exclusions, assertions, provision
     global warnings, profiling, config, testing
     from sqlalchemy import testing  # noqa
     from sqlalchemy.testing import fixtures, engines, exclusions  # noqa
     from sqlalchemy.testing import assertions, warnings, profiling  # noqa
-    from sqlalchemy.testing import config  # noqa
+    from sqlalchemy.testing import config, provision  # noqa
     from sqlalchemy import util  # noqa
 
     warnings.setup_filters()
@@ -619,6 +620,8 @@ def start_test_class(cls):
 def stop_test_class(cls):
     # from sqlalchemy import inspect
     # assert not inspect(testing.db).get_table_names()
+
+    provision.stop_test_class(config, config.db, cls)
     engines.testing_reaper._stop_test_ctx()
     try:
         if not options.low_connections:
index 9b5fa0255573b1793b6144e709f54ca764b44d7a..aa14a9c1addea6e294fc5f4942e2d13fd62e754a 100644 (file)
@@ -300,6 +300,11 @@ def temp_table_keyword_args(cfg, eng):
     )
 
 
+@register.init
+def stop_test_class(config, db, testcls):
+    pass
+
+
 @register.init
 def get_temp_table_name(cfg, eng, base_name):
     """Specify table name for creating a temporary Table.
index 00047296e8154b4349f068755e3e207cc6048462..21878ab661155a9e0bd62c891714678933aa6923 100644 (file)
@@ -416,7 +416,7 @@ class QuotedBindRoundTripTest(fixtures.TestBase):
 
     @testing.provide_metadata
     def test_table_round_trip(self, connection):
-        oracle.RESERVED_WORDS.remove("UNION")
+        oracle.RESERVED_WORDS.discard("UNION")
 
         metadata = self.metadata
         table = Table(