diff options
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r-- | lib/sqlalchemy/dialects/oracle/base.py | 6 | ||||
-rw-r--r-- | lib/sqlalchemy/dialects/oracle/provision.py | 13 | ||||
-rw-r--r-- | lib/sqlalchemy/testing/fixtures.py | 6 | ||||
-rw-r--r-- | lib/sqlalchemy/testing/plugin/plugin_base.py | 7 | ||||
-rw-r--r-- | lib/sqlalchemy/testing/provision.py | 5 |
5 files changed, 32 insertions, 5 deletions
diff --git a/lib/sqlalchemy/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py index 3ead97faf..316dd547e 100644 --- a/lib/sqlalchemy/dialects/oracle/base.py +++ b/lib/sqlalchemy/dialects/oracle/base.py @@ -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" diff --git a/lib/sqlalchemy/dialects/oracle/provision.py b/lib/sqlalchemy/dialects/oracle/provision.py index aadc2c5a9..d51131c0b 100644 --- a/lib/sqlalchemy/dialects/oracle/provision.py +++ b/lib/sqlalchemy/dialects/oracle/provision.py @@ -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) diff --git a/lib/sqlalchemy/testing/fixtures.py b/lib/sqlalchemy/testing/fixtures.py index 54b1cbb46..0ede25176 100644 --- a/lib/sqlalchemy/testing/fixtures.py +++ b/lib/sqlalchemy/testing/fixtures.py @@ -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( [ diff --git a/lib/sqlalchemy/testing/plugin/plugin_base.py b/lib/sqlalchemy/testing/plugin/plugin_base.py index 34e3c5760..b39015852 100644 --- a/lib/sqlalchemy/testing/plugin/plugin_base.py +++ b/lib/sqlalchemy/testing/plugin/plugin_base.py @@ -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: diff --git a/lib/sqlalchemy/testing/provision.py b/lib/sqlalchemy/testing/provision.py index 9b5fa0255..aa14a9c1a 100644 --- a/lib/sqlalchemy/testing/provision.py +++ b/lib/sqlalchemy/testing/provision.py @@ -301,6 +301,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. |