Skip to content

Commit

Permalink
fix: Fix bug for add connection when url is https (#1852)
Browse files Browse the repository at this point in the history
Signed-off-by: Cai Zhang <[email protected]>
  • Loading branch information
xiaocai2333 authored Jan 4, 2024
1 parent d910387 commit 62ef83d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions pymilvus/orm/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def add_connection(self, **kwargs):
)
"""
for alias, config in kwargs.items():
addr, _ = self.__get_full_address(
addr, parsed_uri = self.__get_full_address(
config.get("address", ""),
config.get("uri", ""),
config.get("host", ""),
Expand All @@ -234,6 +234,9 @@ def add_connection(self, **kwargs):
"user": config.get("user", ""),
}

if parsed_uri is not None and parsed_uri.scheme == "https":
alias_config["secure"] = True

self._alias[alias] = alias_config

def __get_full_address(
Expand Down Expand Up @@ -366,7 +369,6 @@ def connect_milvus(**kwargs):
)
kwargs.pop("password")
kwargs.pop("token", None)
kwargs.pop("secure", None)
kwargs.pop("db_name", "")

self._connected_alias[alias] = gh
Expand Down
4 changes: 2 additions & 2 deletions tests/test_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def test_issue_1196(self):
config = {"alias": alias, "host": "localhost", "port": "19531", "user": "root", "password": 12345, "secure": True}
connections.connect(**config)
config = connections.get_connection_addr(alias)
assert config == {"address": 'localhost:19531', "user": 'root'}
assert config == {"address": 'localhost:19531', "user": 'root', "secure": True}

connections.add_connection(default={"host": "localhost", "port": 19531})
config = connections.get_connection_addr("default")
Expand All @@ -370,4 +370,4 @@ def test_issue_1196(self):
connections.connect("default", user="root", password="12345", secure=True)

config = connections.get_connection_addr("default")
assert config == {"address": 'localhost:19531', "user": 'root'}
assert config == {"address": 'localhost:19531', "user": 'root', "secure": True}

0 comments on commit 62ef83d

Please sign in to comment.