|
|
|
@@ -1,8 +1,10 @@ |
|
|
|
import json |
|
|
|
import logging |
|
|
|
import uuid |
|
|
|
from contextlib import contextmanager |
|
|
|
from typing import Any |
|
|
|
|
|
|
|
import psycopg2.errors |
|
|
|
import psycopg2.extras # type: ignore |
|
|
|
import psycopg2.pool # type: ignore |
|
|
|
from pydantic import BaseModel, model_validator |
|
|
|
@@ -147,7 +149,14 @@ class PGVector(BaseVector): |
|
|
|
if not ids: |
|
|
|
return |
|
|
|
with self._get_cursor() as cur: |
|
|
|
cur.execute(f"DELETE FROM {self.table_name} WHERE id IN %s", (tuple(ids),)) |
|
|
|
try: |
|
|
|
cur.execute(f"DELETE FROM {self.table_name} WHERE id IN %s", (tuple(ids),)) |
|
|
|
except psycopg2.errors.UndefinedTable: |
|
|
|
# table not exists |
|
|
|
logging.warning(f"Table {self.table_name} not found, skipping delete operation.") |
|
|
|
return |
|
|
|
except Exception as e: |
|
|
|
raise e |
|
|
|
|
|
|
|
def delete_by_metadata_field(self, key: str, value: str) -> None: |
|
|
|
with self._get_cursor() as cur: |