Skip to content

Commit 0ba4cd1

Browse files
AmirBrahammdrxy
authored andcommitted
Update lancedb.py (#108)
Properly quotes each ID: Each ID is individually wrapped in single quotes Generates correct SQL: Creates proper SQL syntax like id IN ('doc1','doc2') Uses consistent string formatting: Uses f-strings throughout for clarity --------- Co-authored-by: Mason Daugherty <[email protected]>
1 parent 0766fe8 commit 0ba4cd1

File tree

1 file changed

+4
-1
lines changed
  • libs/community/langchain_community/vectorstores

1 file changed

+4
-1
lines changed

libs/community/langchain_community/vectorstores/lancedb.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,10 @@ def delete(
681681
if filter:
682682
tbl.delete(filter)
683683
elif ids:
684-
tbl.delete(f"{self._id_key} in ('{{}}')".format(",".join(ids)))
684+
quoted_ids = ["'" + id_val.replace("'", "''") + "'" for id_val in ids]
685+
ids_clause = ",".join(quoted_ids)
686+
delete_filter = f"{self._id_key} IN ({ids_clause})"
687+
tbl.delete(delete_filter)
685688
elif drop_columns:
686689
if self.api_key is not None:
687690
raise NotImplementedError(

0 commit comments

Comments
 (0)