fix: prevent sqlite-vec duplicate id failures

This commit is contained in:
Peter Steinberger
2026-01-18 13:55:56 +00:00
parent f3ef609839
commit 20c26eb303
3 changed files with 12 additions and 2 deletions

View File

@@ -1406,8 +1406,11 @@ export class MemoryIndexManager {
now,
);
if (vectorReady && embedding.length > 0) {
try {
this.db.prepare(`DELETE FROM ${VECTOR_TABLE} WHERE id = ?`).run(id);
} catch {}
this.db
.prepare(`INSERT OR REPLACE INTO ${VECTOR_TABLE} (id, embedding) VALUES (?, ?)`)
.prepare(`INSERT INTO ${VECTOR_TABLE} (id, embedding) VALUES (?, ?)`)
.run(id, vectorToBlob(embedding));
}
if (this.fts.enabled && this.fts.available) {