Merge "Adapt to SQLAlchemy 1.4"

This commit is contained in:
Zuul 2021-05-13 17:01:12 +00:00 committed by Gerrit Code Review
commit 02f4235230
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()