From 5b7e5eb91b91f869b9b4e3fe0ba85a2a125cb1ba Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sun, 3 Mar 2024 18:55:58 +0000 Subject: [PATCH] Give fts a better chance of working with jsonb messages.content. --- src/ssb.db.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ssb.db.c b/src/ssb.db.c index 3d874f4e..9dd8ee59 100644 --- a/src/ssb.db.c +++ b/src/ssb.db.c @@ -178,11 +178,11 @@ void tf_ssb_db_init(tf_ssb_t* ssb) if (populate_fts) { tf_printf("Populating full-text search...\n"); - _tf_ssb_db_exec(db, "INSERT INTO messages_fts (rowid, content) SELECT rowid, content FROM messages"); + _tf_ssb_db_exec(db, "INSERT INTO messages_fts (rowid, content) SELECT rowid, json(content) FROM messages"); tf_printf("Done.\n"); } - _tf_ssb_db_exec(db, "CREATE TRIGGER IF NOT EXISTS messages_ai AFTER INSERT ON messages BEGIN INSERT INTO messages_fts(rowid, content) VALUES (new.rowid, new.content); END"); + _tf_ssb_db_exec(db, "CREATE TRIGGER IF NOT EXISTS messages_ai AFTER INSERT ON messages BEGIN INSERT INTO messages_fts(rowid, content) VALUES (new.rowid, json(new.content)); END"); _tf_ssb_db_exec(db, "CREATE TRIGGER IF NOT EXISTS messages_ad AFTER DELETE ON messages BEGIN INSERT INTO messages_fts(messages_fts, rowid, content) VALUES ('delete', old.rowid, " "old.content); END");