mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-13 21:05:19 +00:00
Fix syntax error where the previous use of :metadata::text in some sqlachamy/postgres versions doesn't bind at all
Fix syntax error where the previous use of :metadata::text in some sqlachamy/postgres versions doesn't bind the variable at all
This commit is contained in:
parent
66341124a6
commit
f3b0f7d358
1 changed files with 7 additions and 4 deletions
|
|
@ -203,6 +203,8 @@ class PgvectorClient(VectorDBBase):
|
||||||
for item in items:
|
for item in items:
|
||||||
vector = self.adjust_vector_length(item["vector"])
|
vector = self.adjust_vector_length(item["vector"])
|
||||||
# Use raw SQL for BYTEA/pgcrypto
|
# Use raw SQL for BYTEA/pgcrypto
|
||||||
|
# Ensure metadata is converted to its JSON text representation
|
||||||
|
json_metadata = json.dumps(item["metadata"])
|
||||||
self.session.execute(
|
self.session.execute(
|
||||||
text(
|
text(
|
||||||
"""
|
"""
|
||||||
|
|
@ -211,7 +213,7 @@ class PgvectorClient(VectorDBBase):
|
||||||
VALUES (
|
VALUES (
|
||||||
:id, :vector, :collection_name,
|
:id, :vector, :collection_name,
|
||||||
pgp_sym_encrypt(:text, :key),
|
pgp_sym_encrypt(:text, :key),
|
||||||
pgp_sym_encrypt(:metadata::text, :key)
|
pgp_sym_encrypt(:metadata_text, :key)
|
||||||
)
|
)
|
||||||
ON CONFLICT (id) DO NOTHING
|
ON CONFLICT (id) DO NOTHING
|
||||||
"""
|
"""
|
||||||
|
|
@ -221,7 +223,7 @@ class PgvectorClient(VectorDBBase):
|
||||||
"vector": vector,
|
"vector": vector,
|
||||||
"collection_name": collection_name,
|
"collection_name": collection_name,
|
||||||
"text": item["text"],
|
"text": item["text"],
|
||||||
"metadata": json.dumps(item["metadata"]),
|
"metadata_text": json_metadata,
|
||||||
"key": PGVECTOR_PGCRYPTO_KEY,
|
"key": PGVECTOR_PGCRYPTO_KEY,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
@ -255,6 +257,7 @@ class PgvectorClient(VectorDBBase):
|
||||||
if PGVECTOR_PGCRYPTO:
|
if PGVECTOR_PGCRYPTO:
|
||||||
for item in items:
|
for item in items:
|
||||||
vector = self.adjust_vector_length(item["vector"])
|
vector = self.adjust_vector_length(item["vector"])
|
||||||
|
json_metadata = json.dumps(item["metadata"])
|
||||||
self.session.execute(
|
self.session.execute(
|
||||||
text(
|
text(
|
||||||
"""
|
"""
|
||||||
|
|
@ -263,7 +266,7 @@ class PgvectorClient(VectorDBBase):
|
||||||
VALUES (
|
VALUES (
|
||||||
:id, :vector, :collection_name,
|
:id, :vector, :collection_name,
|
||||||
pgp_sym_encrypt(:text, :key),
|
pgp_sym_encrypt(:text, :key),
|
||||||
pgp_sym_encrypt(:metadata::text, :key)
|
pgp_sym_encrypt(:metadata_text, :key)
|
||||||
)
|
)
|
||||||
ON CONFLICT (id) DO UPDATE SET
|
ON CONFLICT (id) DO UPDATE SET
|
||||||
vector = EXCLUDED.vector,
|
vector = EXCLUDED.vector,
|
||||||
|
|
@ -277,7 +280,7 @@ class PgvectorClient(VectorDBBase):
|
||||||
"vector": vector,
|
"vector": vector,
|
||||||
"collection_name": collection_name,
|
"collection_name": collection_name,
|
||||||
"text": item["text"],
|
"text": item["text"],
|
||||||
"metadata": json.dumps(item["metadata"]),
|
"metadata_text": json_metadata,
|
||||||
"key": PGVECTOR_PGCRYPTO_KEY,
|
"key": PGVECTOR_PGCRYPTO_KEY,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue