From 1530798fb6107dac91d905d93dd653a5e4e07646 Mon Sep 17 00:00:00 2001 From: HowardChan Date: Wed, 19 Mar 2025 12:59:44 +0800 Subject: [PATCH 1/2] fix: ensure chunk_ids are correctly handled as VARCHAR array --- lightrag/kg/postgres_impl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lightrag/kg/postgres_impl.py b/lightrag/kg/postgres_impl.py index fcad869c..6a888464 100644 --- a/lightrag/kg/postgres_impl.py +++ b/lightrag/kg/postgres_impl.py @@ -1570,7 +1570,7 @@ TABLES = { content_vector VECTOR, create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, update_time TIMESTAMP, - chunk_id TEXT NULL, + chunk_ids VARCHAR(255)[] NULL, file_path TEXT NULL, CONSTRAINT LIGHTRAG_VDB_ENTITY_PK PRIMARY KEY (workspace, id) )""" @@ -1585,7 +1585,7 @@ TABLES = { content_vector VECTOR, create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, update_time TIMESTAMP, - chunk_id TEXT NULL, + chunk_ids VARCHAR(255)[] NULL, file_path TEXT NULL, CONSTRAINT LIGHTRAG_VDB_RELATION_PK PRIMARY KEY (workspace, id) )""" From 0c39ff00a820ff98e3cccf206861db97eb6f4051 Mon Sep 17 00:00:00 2001 From: HowardChan Date: Wed, 19 Mar 2025 13:01:07 +0800 Subject: [PATCH 2/2] fix: resolve SQL type mismatch and conflict handling in LIGHTRAG_VDB_ENTITY insert query --- lightrag/kg/postgres_impl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lightrag/kg/postgres_impl.py b/lightrag/kg/postgres_impl.py index 6a888464..51f58b4e 100644 --- a/lightrag/kg/postgres_impl.py +++ b/lightrag/kg/postgres_impl.py @@ -1673,7 +1673,7 @@ SQL_TEMPLATES = { """, "upsert_entity": """INSERT INTO LIGHTRAG_VDB_ENTITY (workspace, id, entity_name, content, content_vector, chunk_ids, file_path) - VALUES ($1, $2, $3, $4, $5, $6::varchar[], $7::varchar[]) + VALUES ($1, $2, $3, $4, $5, $6::varchar[], $7) ON CONFLICT (workspace,id) DO UPDATE SET entity_name=EXCLUDED.entity_name, content=EXCLUDED.content, @@ -1684,7 +1684,7 @@ SQL_TEMPLATES = { """, "upsert_relationship": """INSERT INTO LIGHTRAG_VDB_RELATION (workspace, id, source_id, target_id, content, content_vector, chunk_ids, file_path) - VALUES ($1, $2, $3, $4, $5, $6, $7::varchar[], $8::varchar[]) + VALUES ($1, $2, $3, $4, $5, $6, $7::varchar[], $8) ON CONFLICT (workspace,id) DO UPDATE SET source_id=EXCLUDED.source_id, target_id=EXCLUDED.target_id,