fix: prevent sqlite-vec duplicate id failures

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

No files matched your search

+4 -1
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) {