diff --git a/src/storage/sqlite/migration.go b/src/storage/sqlite/migration.go index 47b3515..cf9eb43 100644 --- a/src/storage/sqlite/migration.go +++ b/src/storage/sqlite/migration.go @@ -22,6 +22,7 @@ var migrations = []func(*sql.Tx) error{ m12_remove_feed_sizes, m13_consolidate_feed_states, m14_upgrade_fts5, + m15_update_item_update_trigger, } var maxVersion = int64(len(migrations)) @@ -420,3 +421,14 @@ func m14_upgrade_fts5(tx *sql.Tx) error { _, err := tx.Exec(sql) return err } + +func m15_update_item_update_trigger(tx *sql.Tx) error { + _, err := tx.Exec(` + drop trigger if exists items_au; + create trigger items_au after update of title, content on items begin + insert into search(search, rowid, title, content) values('delete', old.id, old.title, strip_html(old.content)); + insert into search(rowid, title, content) values (new.id, new.title, strip_html(new.content)); + end; + `) + return err +} diff --git a/src/storage/tests/item_test.go b/src/storage/tests/item_test.go index 0ccd79f..b559319 100644 --- a/src/storage/tests/item_test.go +++ b/src/storage/tests/item_test.go @@ -223,16 +223,6 @@ func TestListItems(t *testing.T) { t.Fail() } - // filter by search - search1 := "title111" - have = getItemGuids(db.ListItems(model.ItemFilter{Search: &search1}, 4, true, false)) - want = []string{"item111"} - if !reflect.DeepEqual(have, want) { - t.Logf("want: %#v", want) - t.Logf("have: %#v", have) - t.Fail() - } - // sort by date have = getItemGuids(db.ListItems(model.ItemFilter{}, 4, true, false)) want = []string{"item013", "item012", "item011", "item212"}