Skip to content

Commit

Permalink
Merge pull request #1 from isar/bug/1495
Browse files Browse the repository at this point in the history
Bug/1495
  • Loading branch information
mrclauss authored Feb 23, 2024
2 parents 04886f6 + e506afd commit 7e756f7
Show file tree
Hide file tree
Showing 3 changed files with 627 additions and 144 deletions.
20 changes: 16 additions & 4 deletions packages/isar_core/src/sqlite/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,23 +326,32 @@ fn condition_sql(
ConditionType::StringStartsWith => {
if let Some(IsarValue::String(prefix)) = condition.values.get(0)? {
values.push(IsarValue::String(format!("{}%", escape_wildcard(prefix))));
format!("{} LIKE ? ESCAPE '\\'", property_name)
match condition.case_sensitive {
true => format!("{} LIKE ? ESCAPE '\\'", property_name),
false => format!("LOWER({}) LIKE LOWER(?) ESCAPE '\\'", property_name),
}
} else {
"FALSE".to_string()
}
}
ConditionType::StringEndsWith => {
if let Some(IsarValue::String(postfix)) = condition.values.get(0)? {
values.push(IsarValue::String(format!("%{}", escape_wildcard(postfix))));
format!("{} LIKE ? ESCAPE '\\'", property_name)
match condition.case_sensitive {
true => format!("{} LIKE ? ESCAPE '\\'", property_name),
false => format!("LOWER({}) LIKE LOWER(?) ESCAPE '\\'", property_name),
}
} else {
"FALSE".to_string()
}
}
ConditionType::StringContains => {
if let Some(IsarValue::String(needle)) = condition.values.get(0)? {
values.push(IsarValue::String(format!("%{}%", escape_wildcard(needle))));
format!("{} LIKE ? ESCAPE '\\'", property_name)
match condition.case_sensitive {
true => format!("{} LIKE ? ESCAPE '\\'", property_name),
false => format!("LOWER({}) LIKE LOWER(?) ESCAPE '\\'", property_name),
}
} else {
"FALSE".to_string()
}
Expand All @@ -353,7 +362,10 @@ fn condition_sql(
.replace("*", "%")
.replace("?", "_");
values.push(IsarValue::String(wildcard));
format!("{} LIKE ? ESCAPE '\\'", property_name)
match condition.case_sensitive {
true => format!("{} LIKE ? ESCAPE '\\'", property_name),
false => format!("LOWER({}) LIKE LOWER(?) ESCAPE '\\'", property_name),
}
} else {
"FALSE".to_string()
}
Expand Down
Loading

0 comments on commit 7e756f7

Please sign in to comment.