Compare commits

...

3 Commits

Author SHA1 Message Date
iequidoo
15df57900b feat: Try SQLite FTS5 (#5052) 2024-03-04 15:28:51 -03:00
dependabot[bot]
12587684ca Merge pull request #5305 from deltachat/dependabot/cargo/tempfile-3.10.1 2024-03-03 20:44:06 +00:00
dependabot[bot]
0c1d578207 chore(cargo): bump tempfile from 3.10.0 to 3.10.1
Bumps [tempfile](https://github.com/Stebalien/tempfile) from 3.10.0 to 3.10.1.
- [Changelog](https://github.com/Stebalien/tempfile/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Stebalien/tempfile/compare/v3.10.0...v3.10.1)

---
updated-dependencies:
- dependency-name: tempfile
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-03 08:05:01 +00:00
4 changed files with 35 additions and 5 deletions

4
Cargo.lock generated
View File

@@ -4860,9 +4860,9 @@ checksum = "094c9f64d6de9a8506b1e49b63a29333b37ed9e821ee04be694d431b3264c3c5"
[[package]]
name = "tempfile"
version = "3.10.0"
version = "3.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67"
checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1"
dependencies = [
"cfg-if",
"fastrand",

View File

@@ -17,7 +17,7 @@ deltachat = { path = ".." }
num-traits = "0.2"
schemars = "0.8.13"
serde = { version = "1.0", features = ["derive"] }
tempfile = "3.9.0"
tempfile = "3.10.1"
log = "0.4"
async-channel = { version = "2.0.0" }
futures = { version = "0.3.30" }

View File

@@ -1099,12 +1099,14 @@ impl Context {
.query_map(
"SELECT m.id AS id
FROM msgs m
INNER JOIN msgs_search ms
ON m.id=ms.rowid
LEFT JOIN contacts ct
ON m.from_id=ct.id
WHERE m.chat_id=?
AND m.hidden=0
AND ct.blocked=0
AND txt LIKE ?
AND ms.txt LIKE ?
ORDER BY m.timestamp,m.id;",
(chat_id, str_like_in_text),
|row| row.get::<_, MsgId>("id"),
@@ -1132,6 +1134,8 @@ impl Context {
.query_map(
"SELECT m.id AS id
FROM msgs m
INNER JOIN msgs_search ms
ON m.id=ms.rowid
LEFT JOIN contacts ct
ON m.from_id=ct.id
LEFT JOIN chats c
@@ -1140,7 +1144,7 @@ impl Context {
AND m.hidden=0
AND c.blocked!=1
AND ct.blocked=0
AND m.txt LIKE ?
AND ms.txt LIKE ?
ORDER BY m.id DESC LIMIT 1000",
(str_like_in_text,),
|row| row.get::<_, MsgId>("id"),
@@ -1537,6 +1541,8 @@ mod tests {
msg2.set_text("barbaz".to_string());
send_msg(&alice, chat.id, &mut msg2).await?;
alice.send_text(chat.id, "Δ-Chat").await;
// Global search with a part of text finds the message.
let res = alice.search_msgs(None, "ob").await?;
assert_eq!(res.len(), 1);
@@ -1549,6 +1555,12 @@ mod tests {
assert_eq!(res.first(), Some(&msg2.id));
assert_eq!(res.get(1), Some(&msg1.id));
// Search is case-insensitive.
for chat_id in [None, Some(chat.id)] {
let res = alice.search_msgs(chat_id, "δ-chat").await?;
assert_eq!(res.len(), 1);
}
// Global search with longer text does not find any message.
let res = alice.search_msgs(None, "foobarbaz").await?;
assert!(res.is_empty());

View File

@@ -911,6 +911,24 @@ CREATE INDEX msgs_status_updates_index2 ON msgs_status_updates (uid);
.await?;
}
if dbversion < 111 {
sql.execute_migration(
"CREATE VIRTUAL TABLE msgs_search USING fts5(txt, content='msgs', content_rowid='id'); \
CREATE TRIGGER msgs_search_insert AFTER INSERT ON msgs BEGIN \
INSERT INTO msgs_search (rowid, txt) VALUES (new.id, new.txt); \
END; \
CREATE TRIGGER msgs_search_delete AFTER DELETE ON msgs BEGIN \
INSERT INTO msgs_search (msgs_search, rowid, txt) VALUES ('delete', old.id, old.txt); \
END; \
CREATE TRIGGER msgs_search_update AFTER UPDATE ON msgs BEGIN \
INSERT INTO msgs_search (msgs_search, rowid, txt) VALUES ('delete', old.id, old.txt); \
INSERT INTO msgs_search (rowid, txt) VALUES (new.id, new.txt); \
END; \
INSERT INTO msgs_search (msgs_search) VALUES ('rebuild');",
111,
).await?;
}
let new_version = sql
.get_raw_config_int(VERSION_CFG)
.await?