@clawchatsai/connector 0.0.80 → 0.0.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server.js +24 -19
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -390,24 +390,25 @@ function closeAllDbs() {
|
|
|
390
390
|
}
|
|
391
391
|
|
|
392
392
|
function _createFtsTables(db) {
|
|
393
|
-
db.exec(
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
393
|
+
// Each statement must be a separate db.exec() call — SQLite's multi-statement exec
|
|
394
|
+
// splits on every semicolon including those inside BEGIN...END trigger bodies,
|
|
395
|
+
// which breaks trigger creation with an "unrecognized token" error.
|
|
396
|
+
db.exec(`CREATE VIRTUAL TABLE messages_fts USING fts5(
|
|
397
|
+
content,
|
|
398
|
+
content=messages,
|
|
399
|
+
content_rowid=rowid,
|
|
400
|
+
tokenize='porter unicode61 tokenchars x27'
|
|
401
|
+
)`);
|
|
402
|
+
db.exec(`CREATE TRIGGER messages_ai AFTER INSERT ON messages BEGIN
|
|
403
|
+
INSERT INTO messages_fts(rowid, content) VALUES (new.rowid, new.content);
|
|
404
|
+
END`);
|
|
405
|
+
db.exec(`CREATE TRIGGER messages_ad AFTER DELETE ON messages BEGIN
|
|
406
|
+
INSERT INTO messages_fts(messages_fts, rowid, content) VALUES('delete', old.rowid, old.content);
|
|
407
|
+
END`);
|
|
408
|
+
db.exec(`CREATE TRIGGER messages_au AFTER UPDATE ON messages BEGIN
|
|
409
|
+
INSERT INTO messages_fts(messages_fts, rowid, content) VALUES('delete', old.rowid, old.content);
|
|
410
|
+
INSERT INTO messages_fts(rowid, content) VALUES (new.rowid, new.content);
|
|
411
|
+
END`);
|
|
411
412
|
}
|
|
412
413
|
|
|
413
414
|
function _dropFtsTables(db) {
|
|
@@ -482,7 +483,11 @@ function migrate(db) {
|
|
|
482
483
|
"SELECT name FROM sqlite_master WHERE type='table' AND name='messages_fts'"
|
|
483
484
|
).get();
|
|
484
485
|
if (!hasFts) {
|
|
485
|
-
|
|
486
|
+
try {
|
|
487
|
+
_createFtsTables(db);
|
|
488
|
+
} catch (ftsCreateErr) {
|
|
489
|
+
console.error('[DB] messages_fts creation failed, search disabled:', ftsCreateErr.message);
|
|
490
|
+
}
|
|
486
491
|
} else {
|
|
487
492
|
// Migration: rebuild FTS table if tokenizer is outdated (missing tokenchars for apostrophe support).
|
|
488
493
|
// Old tokenizer split "there's" into ["there", "s"] causing contraction searches to return 0 results.
|