From 45c2ec7eeea300509d2a13c8a9edbb2bf3d0ed76 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Thu, 4 Jul 2024 08:46:58 -0700 Subject: [PATCH] upsert instead of insert to fts_metadata --- core/indexing/FullTextSearch.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/indexing/FullTextSearch.ts b/core/indexing/FullTextSearch.ts index e69a33bba..1e60d2c6c 100644 --- a/core/indexing/FullTextSearch.ts +++ b/core/indexing/FullTextSearch.ts @@ -59,7 +59,12 @@ export class FullTextSearchCodebaseIndex implements CodebaseIndex { [item.path, chunk.content], ); await db.run( - "INSERT INTO fts_metadata (id, path, cacheKey, chunkId) VALUES (?, ?, ?, ?)", + `INSERT INTO fts_metadata (id, path, cacheKey, chunkId) + VALUES (?, ?, ?, ?) + ON CONFLICT(id) DO UPDATE SET + path = excluded.path, + cacheKey = excluded.cacheKey, + chunkId = excluded.chunkId`, [lastID, item.path, item.cacheKey, chunk.id], ); }