Remove logic for SQLAlchemy < 1.4

Change I8629225eeb51d95264d8a3e4b719268bb1597f4f bumped the minimum
version for SQLAlchemy to 1.4, meaning this logic is now dead. Remove
it.

Change-Id: I4d4a58e15e840ecfa63e15c709617a65642c8323
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2023-03-22 12:11:12 +00:00
parent 7d62b3664e
commit 56d79bf378
3 changed files with 3 additions and 46 deletions

View File

@ -22,7 +22,6 @@ import logging
import os
import re
import time
from urllib import parse
import debtcollector.removals
import debtcollector.renames
@ -130,31 +129,6 @@ def _setup_logging(connection_debug=0):
logger.setLevel(logging.WARNING)
def _extend_url_parameters(url, connection_parameters):
# TODO(zzzeek): remove hasattr() conditional when SQLAlchemy 1.4 is the
# minimum version in requirements; call update_query_string()
# unconditionally
if hasattr(url, "update_query_string"):
return url.update_query_string(connection_parameters, append=True)
# TODO(zzzeek): remove the remainder of this method when SQLAlchemy 1.4
# is the minimum version in requirements
for key, value in parse.parse_qs(
connection_parameters).items():
if key in url.query:
existing = url.query[key]
if not isinstance(existing, list):
url.query[key] = existing = utils.to_list(existing)
existing.extend(value)
value = existing
else:
url.query[key] = value
if len(value) == 1:
url.query[key] = value[0]
return url
def _vet_url(url):
if "+" not in url.drivername and not url.drivername.startswith("sqlite"):
if url.drivername.startswith("mysql"):
@ -201,7 +175,7 @@ def create_engine(sql_connection, sqlite_fk=False, mysql_sql_mode=None,
url = utils.make_url(sql_connection)
if connection_parameters:
url = _extend_url_parameters(url, connection_parameters)
url = url.update_query_string(connection_parameters, append=True)
_vet_url(url)

View File

@ -493,15 +493,7 @@ class BackendImpl(object, metaclass=abc.ABCMeta):
"""
url = utils.make_url(base_url)
# TODO(zzzeek): 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=ident)
else:
# TODO(zzzeek): remove when SQLAlchemy 1.4
# is the minimum version in requirements
url.database = ident
return url

View File

@ -416,16 +416,7 @@ class TestNonExistentDatabase(
super(TestNonExistentDatabase, self).setUp()
url = utils.make_url(self.engine.url)
# TODO(zzzeek): remove hasattr() conditional in favor of "url.set()"
# when SQLAlchemy 1.4 is the minimum version in requirements
if hasattr(url, "set"):
self.url = url.set(database="non_existent_database")
else:
# TODO(zzzeek): remove when SQLAlchemy 1.4
# is the minimum version in requirements
url.database = 'non_existent_database'
self.url = url
def test_raise(self):
matched = self.assertRaises(