diff --git a/src/snowflake/cli/app/snow_connector.py b/src/snowflake/cli/app/snow_connector.py index d2806b7cd5..b7b5432307 100644 --- a/src/snowflake/cli/app/snow_connector.py +++ b/src/snowflake/cli/app/snow_connector.py @@ -21,7 +21,12 @@ import snowflake.connector from click.exceptions import ClickException -from snowflake.cli.api.config import get_connection_dict, get_default_connection_dict +from snowflake.cli.api.cli_global_context import cli_context +from snowflake.cli.api.config import ( + get_connection_dict, + get_default_connection_dict, + get_default_connection_name, +) from snowflake.cli.api.constants import DEFAULT_SIZE_LIMIT_MB from snowflake.cli.api.exceptions import ( InvalidConnectionConfiguration, @@ -70,6 +75,9 @@ def connect_to_snowflake( connection_parameters = {} # we will apply overrides in next step else: connection_parameters = get_default_connection_dict() + cli_context.connection_context.set_connection_name( + get_default_connection_name() + ) # Apply overrides to connection details for key, value in overrides.items(): diff --git a/tests_integration/test_connection.py b/tests_integration/test_connection.py index e6bc70b2f7..4128c2e1fc 100644 --- a/tests_integration/test_connection.py +++ b/tests_integration/test_connection.py @@ -26,6 +26,7 @@ def test_connection_test_simple(runner): result = runner.invoke_with_connection_json(["connection", "test"]) assert result.exit_code == 0, result.output + assert result.json["Connection name"] == "integration" assert result.json["Status"] == "OK"