Skip to content

Commit

Permalink
Fix rename collection raise cannot be None error (#1615)
Browse files Browse the repository at this point in the history
See also: milvus-io/milvus#25872

Signed-off-by: yangxuan <[email protected]>
  • Loading branch information
XuanYang-cn authored Jul 24, 2023
1 parent 0ade161 commit c28ceb1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
11 changes: 8 additions & 3 deletions pymilvus/client/grpc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,17 @@ def list_collections(self, timeout: Optional[float] = None):

@retry_on_rpc_failure()
def rename_collections(
self, old_name: str, new_db_name: str, new_name: str, timeout: Optional[float] = None
self,
old_name: str,
new_name: str,
new_db_name: str = "default",
timeout: Optional[float] = None,
):
check_pass_param(collection_name=new_name)
check_pass_param(collection_name=new_db_name)
check_pass_param(collection_name=old_name)
request = Prepare.rename_collections_request(old_name, new_db_name, new_name)
if new_db_name:
check_pass_param(db_name=new_db_name)
request = Prepare.rename_collections_request(old_name, new_name, new_db_name)
rf = self._stub.RenameCollection.future(request, timeout=timeout)
response = rf.result()

Expand Down
2 changes: 1 addition & 1 deletion pymilvus/client/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def show_collections_request(cls, collection_names: Optional[List[str]] = None):
return req

@classmethod
def rename_collections_request(cls, old_name: str, new_db_name: str, new_name: str):
def rename_collections_request(cls, old_name: str, new_name: str, new_db_name: str):
return milvus_types.RenameCollectionRequest(
oldName=old_name, newName=new_name, newDBName=new_db_name
)
Expand Down
5 changes: 4 additions & 1 deletion pymilvus/orm/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,10 @@ def rename_collection(
>>> False
"""
return _get_connection(using).rename_collections(
old_collection_name, new_db_name, new_collection_name, timeout=timeout
old_name=old_collection_name,
new_name=new_collection_name,
new_db_name=new_db_name,
timeout=timeout,
)


Expand Down

0 comments on commit c28ceb1

Please sign in to comment.