Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Upcoming (TBD)
==============

Breaking Changes
--------
* Remove support for deprecated environment variable `$MYSQL_UNIX_PORT`.


1.75.0 (2026/06/20)
==============

Expand Down
11 changes: 0 additions & 11 deletions mycli/cli_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
47 changes: 20 additions & 27 deletions test/pytests/test_cli_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 = (
Expand Down
Loading