From: Mike Bayer Date: Mon, 9 Dec 2024 17:36:56 +0000 (-0500) Subject: ensure db_opts are honored X-Git-Tag: rel_2_0_37~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5d784ac92c67ba79d18430ee51b9ddc66b26a7c5;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git ensure db_opts are honored for provision.py that adds db_opts these need to be used in all cases for testing_engine() that is using that same database driver References: #12159 Change-Id: I15c46a375ab05ef94c9a7d19000a3d8641de43bf (cherry picked from commit 3226f99dce77bb75698a7c9366f6fd07ab4d29ee) --- diff --git a/lib/sqlalchemy/testing/engines.py b/lib/sqlalchemy/testing/engines.py index 7cae807eb4..08fbe248e1 100644 --- a/lib/sqlalchemy/testing/engines.py +++ b/lib/sqlalchemy/testing/engines.py @@ -330,16 +330,18 @@ def testing_engine( url = url or config.db.url url = make_url(url) - if options is None: - if config.db is None or url.drivername == config.db.url.drivername: - options = config.db_opts - else: - options = {} - elif config.db is not None and url.drivername == config.db.url.drivername: - default_opt = config.db_opts.copy() - default_opt.update(options) - engine = create_engine(url, **options) + if ( + config.db is None or url.drivername == config.db.url.drivername + ) and config.db_opts: + use_options = config.db_opts.copy() + else: + use_options = {} + + if options is not None: + use_options.update(options) + + engine = create_engine(url, **use_options) if sqlite_savepoint and engine.name == "sqlite": # apply SQLite savepoint workaround @@ -370,9 +372,9 @@ def testing_engine( if ( isinstance(engine.pool, pool.QueuePool) - and "pool" not in options - and "pool_timeout" not in options - and "max_overflow" not in options + and "pool" not in use_options + and "pool_timeout" not in use_options + and "max_overflow" not in use_options ): engine.pool._timeout = 0 engine.pool._max_overflow = 0