From eca7ad0f7145ca1dade190f3809a94885426ef96 Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Sat, 4 Jul 2026 14:53:34 -0400 Subject: [PATCH] remove support for tcp and socket DSN schemes These were undocumented, and socket:// in particular could not have worked correctly. --- changelog.md | 5 +++++ mycli/packages/cli_utils.py | 8 ++------ test/pytests/test_cli_utils.py | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/changelog.md b/changelog.md index b29259ba..a1a14bdf 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,11 @@ Upcoming (TBD) ============== +Breaking Changes +--------- +* Remove undocumented support for `tcp://` and `socket://` DSNs. + + Documentation --------- * Fix a typo in myclirc commentary. diff --git a/mycli/packages/cli_utils.py b/mycli/packages/cli_utils.py index 482348ce..ece9353e 100644 --- a/mycli/packages/cli_utils.py +++ b/mycli/packages/cli_utils.py @@ -23,11 +23,7 @@ def is_valid_connection_scheme(text: str) -> tuple[bool, str | None]: # exit early if the text does not resemble a DSN URI if "://" not in text: return False, None - scheme = text.split("://")[0] - if scheme.startswith('mysql+'): - return True, None - if scheme.startswith('mysqlx+'): - return True, None - if scheme in ("mysql", "mysqlx", "tcp", "socket"): + scheme = text.split("://")[0].split("+")[0] + if scheme in ("mysql", "mysqlx"): return True, None return False, scheme diff --git a/test/pytests/test_cli_utils.py b/test/pytests/test_cli_utils.py index 01fa66ae..2f86f05f 100644 --- a/test/pytests/test_cli_utils.py +++ b/test/pytests/test_cli_utils.py @@ -38,8 +38,8 @@ def test_filtered_sys_argv_appends_empty_password_sentinel(monkeypatch, password ('mysql+pymysql://user@localhost/db', True, None), ('mysqlx://user@localhost/db', True, None), ('mysqlx+pymysql://user@localhost/db', True, None), - ('tcp://localhost:3306', True, None), - ('socket:///tmp/mysql.sock', True, None), + ('tcp://localhost:3306', False, 'tcp'), + ('socket:///tmp/mysql.sock', False, 'socket'), ('ssh://user@example.com', False, 'ssh'), ('postgres://user@localhost/db', False, 'postgres'), ('http://example.com', False, 'http'),