Adapt to SQLAlchemy 1.4

This patch makes the necessary change to adapt to the SQLAlchemy 1.4
release in a way that is still compatible with the currently pinned 1.3
versions.

This is related to the overall effort to bump SQLAlchemy to 1.4
https://review.opendev.org/c/openstack/requirements/+/788339

Co-Authored-By: Mike Bayer <mike_mp@zzzcomputing.com>

Closes-Bug: #1926426
Change-Id: I8a0ab3b91b4203ab603caac02ee5132be7890e9a
This commit is contained in:
Balazs Gibizer 2021-05-03 10:44:52 +02:00
parent 294b30b281
commit 39a617752f
1 changed files with 10 additions and 1 deletions

View File

@ -706,7 +706,16 @@ class CellV2Commands(object):
# worry about parsing and splitting a URL which could have special
# characters in the password, which makes parsing a nightmare.
url = sqla_url.make_url(connection)
url.database = url.database + '_cell0'
# TODO(gibi): remove hasattr() conditional in favor of "url.set()"
# when SQLAlchemy 1.4 is the minimum version in requirements
if hasattr(url, "set"):
url = url.set(database=url.database + '_cell0')
else:
# TODO(zzzeek): remove when SQLAlchemy 1.4
# is the minimum version in requirements
url.database = url.database + '_cell0'
return urlparse.unquote(str(url))
dbc = database_connection or cell0_default_connection()