Skip to content

Commit

Permalink
remove useless condition
Browse files Browse the repository at this point in the history
  • Loading branch information
anakin87 committed Jan 23, 2024
1 parent 685462d commit de2b3f4
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from psycopg.rows import dict_row
from psycopg.sql import SQL, Identifier
from psycopg.sql import Literal as SQLLiteral
from psycopg.types.json import Json
from psycopg.types.json import Jsonb

from pgvector.psycopg import register_vector

Expand All @@ -25,11 +25,11 @@
id VARCHAR(128) PRIMARY KEY,
embedding VECTOR({embedding_dimension}),
content TEXT,
dataframe JSON,
dataframe JSONB,
blob_data BYTEA,
blob_meta JSON,
blob_meta JSONB,
blob_mime_type VARCHAR(255),
meta JSON)
meta JSONB)
"""

INSERT_STATEMENT = """
Expand Down Expand Up @@ -332,11 +332,11 @@ def _from_haystack_to_pg_documents(self, documents: List[Document]) -> List[Dict

blob = document.blob
db_document["blob_data"] = blob.data if blob else None
db_document["blob_meta"] = Json(blob.meta) if blob and blob.meta else None
db_document["blob_meta"] = Jsonb(blob.meta) if blob and blob.meta else None
db_document["blob_mime_type"] = blob.mime_type if blob and blob.mime_type else None

db_document["dataframe"] = Json(db_document["dataframe"]) if db_document["dataframe"] else None
db_document["meta"] = Json(db_document["meta"])
db_document["dataframe"] = Jsonb(db_document["dataframe"]) if db_document["dataframe"] else None
db_document["meta"] = Jsonb(db_document["meta"])

db_documents.append(db_document)

Expand All @@ -354,9 +354,6 @@ def _from_pg_to_haystack_documents(self, documents: List[Dict[str, Any]]) -> Lis
blob_meta = haystack_dict.pop("blob_meta")
blob_mime_type = haystack_dict.pop("blob_mime_type")

if not haystack_dict["meta"]:
haystack_dict["meta"] = {}

haystack_document = Document.from_dict(haystack_dict)

if blob_data:
Expand Down

0 comments on commit de2b3f4

Please sign in to comment.