Skip to content

Commit

Permalink
Fix db query
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRustyPickle committed Jul 31, 2023
1 parent 695f282 commit a394300
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/utility/sub_func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,18 @@ pub fn get_search_data(
if !tags.is_empty() {
let all_tags = tags.split(", ");
let tag_conditions = all_tags
.map(|tag| format!(r#""," || tags || "," LIKE "%{}%""#, tag))
.map(|tag| {
format!(
r#"CASE
WHEN tags LIKE "{}, %" THEN 1
WHEN tags LIKE "%, {}" THEN 1
WHEN tags LIKE "%, {}," THEN 1
WHEN tags = "{}" THEN 1
ELSE 0
END = 1"#,
tag, tag, tag, tag
)
})
.collect::<Vec<String>>()
.join(" OR ");
query.push_str(&format!(" AND ({})", tag_conditions));
Expand Down

0 comments on commit a394300

Please sign in to comment.