diff --git a/changelog.md b/changelog.md index 69aee6fc..7c0b235a 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,11 @@ +Upcoming (TBD) +============== + +Breaking Changes +-------- +* Remove support for deprecated environment variable `$MYSQL_UNIX_PORT`. + + 1.75.0 (2026/06/20) ============== diff --git a/mycli/cli_runner.py b/mycli/cli_runner.py index 6b35e657..a5deb9d7 100644 --- a/mycli/cli_runner.py +++ b/mycli/cli_runner.py @@ -97,17 +97,6 @@ def run_from_cli_args(cli_args: 'CliArgs', client_factory: ClientFactory) -> Non if cli_args.list_ssh_config: sys.exit(main_list_ssh_config(mycli, cli_args)) - if 'MYSQL_UNIX_PORT' in os.environ: - # deprecated 2026-03 - click.secho( - "The MYSQL_UNIX_PORT environment variable is deprecated in favor of MYSQL_UNIX_SOCKET. " - "MYSQL_UNIX_PORT will be removed in a future release.", - err=True, - fg="red", - ) - if not cli_args.socket: - cli_args.socket = os.environ['MYSQL_UNIX_PORT'] - if 'DSN' in os.environ: # deprecated 2026-03 click.secho( diff --git a/test/pytests/test_cli_runner.py b/test/pytests/test_cli_runner.py index ed9a44ca..c634e436 100644 --- a/test/pytests/test_cli_runner.py +++ b/test/pytests/test_cli_runner.py @@ -118,33 +118,6 @@ def test_run_from_cli_args_rejects_conflicting_format_flags( assert secho_calls == [(message, {'err': True, 'fg': 'red'})] -def test_run_from_cli_args_uses_deprecated_mysql_unix_port_and_database_alias( - monkeypatch: pytest.MonkeyPatch, -) -> None: - cli_args = make_cli_args() - cli_args.database = 'prod' - client = DummyMyCli( - config={ - **default_config(), - 'alias_dsn': {'prod': 'mysql://dsn_user:dsn_pass@dsn_host:3307/dsn_db'}, - } - ) - secho_calls: list[str] = [] - monkeypatch.setenv('MYSQL_UNIX_PORT', '/tmp/mysql.sock') - monkeypatch.setattr(cli_runner.click, 'secho', lambda text, **_kwargs: secho_calls.append(text)) - - run_with_client(monkeypatch, cli_args, client) - - assert client.dsn_alias == 'prod' - assert client.connect_calls[-1]['database'] == 'dsn_db' - assert client.connect_calls[-1]['user'] == 'dsn_user' - assert client.connect_calls[-1]['passwd'] == 'dsn_pass' - assert client.connect_calls[-1]['host'] == 'dsn_host' - assert client.connect_calls[-1]['port'] == 3307 - assert client.connect_calls[-1]['socket'] == '/tmp/mysql.sock' - assert any('MYSQL_UNIX_PORT environment variable is deprecated' in call for call in secho_calls) - - def test_run_from_cli_args_reports_missing_dsn(monkeypatch: pytest.MonkeyPatch) -> None: cli_args = make_cli_args() cli_args.dsn = 'missing' @@ -165,6 +138,26 @@ def test_run_from_cli_args_reports_missing_dsn(monkeypatch: pytest.MonkeyPatch) ] +def test_run_from_cli_args_treats_database_as_dsn_alias(monkeypatch: pytest.MonkeyPatch) -> None: + cli_args = make_cli_args() + cli_args.database = 'prod' + client = DummyMyCli( + config={ + **default_config(), + 'alias_dsn': {'prod': 'mysql://u:p@h/db'}, + } + ) + + run_with_client(monkeypatch, cli_args, client) + + assert client.dsn_alias == 'prod' + connect_call = client.connect_calls[-1] + assert connect_call['user'] == 'u' + assert connect_call['passwd'] == 'p' + assert connect_call['host'] == 'h' + assert connect_call['database'] == 'db' + + def test_run_from_cli_args_maps_dsn_ssl_parameters(monkeypatch: pytest.MonkeyPatch) -> None: cli_args = make_cli_args() cli_args.dsn = (