From 8246ba148ed358c16b1166b394c25ef8324902ac Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 2 May 2020 14:55:30 +1000 Subject: [PATCH] fix case sensitivity of notetype/template searches --- rslib/src/search/sqlwriter.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/rslib/src/search/sqlwriter.rs b/rslib/src/search/sqlwriter.rs index 9d73eb552..2ac4ed6a9 100644 --- a/rslib/src/search/sqlwriter.rs +++ b/rslib/src/search/sqlwriter.rs @@ -258,11 +258,12 @@ impl SqlWriter<'_> { write!(self.sql, "c.ord = {}", n).unwrap(); } TemplateKind::Name(name) => { - if let Some(glob) = glob_to_re(name) { + if let Some(re) = glob_to_re(name) { + let re = format!("(?i){}", re); self.sql.push_str( "(n.mid,c.ord) in (select ntid,ord from templates where name regexp ?)", ); - self.args.push(glob); + self.args.push(re); } else { self.sql.push_str( "(n.mid,c.ord) in (select ntid,ord from templates where name = ?)", @@ -275,10 +276,11 @@ impl SqlWriter<'_> { } fn write_note_type(&mut self, nt_name: &str) -> Result<()> { - if let Some(glob) = glob_to_re(nt_name) { + if let Some(re) = glob_to_re(nt_name) { + let re = format!("(?i){}", re); self.sql .push_str("n.mid in (select id from notetypes where name regexp ?)"); - self.args.push(glob); + self.args.push(re); } else { self.sql .push_str("n.mid in (select id from notetypes where name = ?)"); @@ -597,7 +599,7 @@ mod test { s(ctx, "note:basic*"), ( "(n.mid in (select id from notetypes where name regexp ?))".into(), - vec!["basic.*".into()] + vec!["(?i)basic.*".into()] ) );