From 4e58c7d7da236ce662633ea1fd7025b28b6d67be Mon Sep 17 00:00:00 2001 From: pengjunfeng11 <34857167+pengjunfeng11@users.noreply.github.com> Date: Mon, 17 Mar 2025 10:47:17 +0800 Subject: [PATCH] Update postgres_impl.py There is aBUG. When lighttrag uses the postgres@15 version, there will be an error.The BUG detail as follow: PostgreSQL database, error:subquery in FROM must have an alias HINT: For example, FROM (SELECT ...) [AS] foo. It roughly means that there is an error in SQL template, and you need to use the alias alias to declare the content of the subquery. --- 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 6a3e7c5f..99e4f5c4 100644 --- a/lightrag/kg/postgres_impl.py +++ b/lightrag/kg/postgres_impl.py @@ -1739,7 +1739,7 @@ SQL_TEMPLATES = { FROM LIGHTRAG_VDB_ENTITY where workspace=$1 AND chunk_id IN (SELECT chunk_id FROM relevant_chunks) - ) + ) as chunk_distances WHERE distance>$2 ORDER BY distance DESC LIMIT $3 @@ -1756,7 +1756,7 @@ SQL_TEMPLATES = { FROM LIGHTRAG_DOC_CHUNKS where workspace=$1 AND id IN (SELECT chunk_id FROM relevant_chunks) - ) + ) as chunk_distances WHERE distance>$2 ORDER BY distance DESC LIMIT $3