From 32ec56194b3aeeee7a0608dc9d6408b3d99e8223 Mon Sep 17 00:00:00 2001 From: Ian Date: Tue, 9 Jan 2024 04:26:29 +0800 Subject: [PATCH] community: fix myscale delete function bug (#15675) Now the SQL used to delete vector doc from myscale is as follow: ```sql DELETE FROM collection WHERE id = '1' AND id = '2' AND id = '3' ``` But the expected one should be ```sql DELETE FROM collection WHERE id IN ('1', '2', '3') ``` --- libs/community/langchain_community/vectorstores/myscale.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/myscale.py b/libs/community/langchain_community/vectorstores/myscale.py index e5a18576cde..bc90b27c0e5 100644 --- a/libs/community/langchain_community/vectorstores/myscale.py +++ b/libs/community/langchain_community/vectorstores/myscale.py @@ -470,8 +470,9 @@ class MyScale(VectorStore): ids is None and where_str is None ), "You need to specify where to be deleted! Either with `ids` or `where_str`" conds = [] - if ids: - conds.extend([f"{self.config.column_map['id']} = '{id}'" for id in ids]) + if ids and len(ids) > 0: + id_list = ", ".join([f"'{id}'" for id in ids]) + conds.append(f"{self.config.column_map['id']} IN ({id_list})") if where_str: conds.append(where_str) assert len(conds) > 0