aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris2022-07-09 20:06:54 +0200
committerJoris2022-07-09 20:06:54 +0200
commit72061e8cefc03d12264c006dfd90cb1ee5310d3e (patch)
treed3c11c69de9cee12e1d736f76e69fda25d65c037
parent79cde4e391395e7397fa5215797055a7e7ed88cd (diff)
Fix payment search by sub word
It tried to search for exact words, minus accents and case. Use the same method that was successfully working when searching a category.
-rw-r--r--src/db/payments.rs2
-rw-r--r--src/utils/text.rs2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/db/payments.rs b/src/db/payments.rs
index f20dbdc..0082736 100644
--- a/src/db/payments.rs
+++ b/src/db/payments.rs
@@ -484,7 +484,7 @@ ORDER BY
);
let res = sqlx::query(&query)
- .bind(text::format_search(&format!("%{}%", payment_name)))
+ .bind(text::format_search(&payment_name))
.map(|row: SqliteRow| row.get("category_id"))
.fetch_one(pool)
.await;
diff --git a/src/utils/text.rs b/src/utils/text.rs
index c07ccee..3a6f495 100644
--- a/src/utils/text.rs
+++ b/src/utils/text.rs
@@ -1,5 +1,5 @@
pub fn format_search(str: &String) -> String {
- unaccent(&str.to_lowercase())
+ format!("%{}%", unaccent(&str.to_lowercase()))
}
pub fn unaccent(str: &String) -> String {