Skip to content

Commit

Permalink
feat: change fulltext to do multi substring match (#1660)
Browse files Browse the repository at this point in the history
  • Loading branch information
lilydjwg authored Feb 19, 2024
1 parent 38dfaab commit 2a65f89
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions atuin-client/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ impl Database for Sqlite {

match search_mode {
SearchMode::Prefix => sql.and_where_like_left("command", query),
SearchMode::FullText => sql.and_where_like_any("command", query),
_ => {
// don't recompile the regex on successive calls!
lazy_static! {
Expand All @@ -453,6 +452,7 @@ impl Database for Sqlite {
None => (false, query_part),
};

#[allow(clippy::if_same_then_else)]
let param = if query_part == "|" {
if !is_or {
is_or = true;
Expand All @@ -468,6 +468,8 @@ impl Database for Sqlite {
format!("{glob}{term}{glob}")
} else if is_inverse {
format!("{glob}{query_part}{glob}")
} else if search_mode == SearchMode::FullText {
format!("{glob}{query_part}{glob}")
} else {
query_part.split("").join(glob)
};
Expand Down Expand Up @@ -817,7 +819,10 @@ mod test {
assert_search_eq(&db, SearchMode::FullText, FilterMode::Global, "/home", 1)
.await
.unwrap();
assert_search_eq(&db, SearchMode::FullText, FilterMode::Global, "ls ", 0)
assert_search_eq(&db, SearchMode::FullText, FilterMode::Global, "ls ho", 1)
.await
.unwrap();
assert_search_eq(&db, SearchMode::FullText, FilterMode::Global, "hm", 0)
.await
.unwrap();
}
Expand Down

0 comments on commit 2a65f89

Please sign in to comment.