ui/sqlite3: add has:attachment query
parent
35e34d1c09
commit
c9c4e1ea60
|
@ -52,6 +52,7 @@ pub enum Query {
|
||||||
AllText(String),
|
AllText(String),
|
||||||
/* * * * */
|
/* * * * */
|
||||||
Flags(Vec<String>),
|
Flags(Vec<String>),
|
||||||
|
HasAttachment,
|
||||||
And(Box<Query>, Box<Query>),
|
And(Box<Query>, Box<Query>),
|
||||||
Or(Box<Query>, Box<Query>),
|
Or(Box<Query>, Box<Query>),
|
||||||
Not(Box<Query>),
|
Not(Box<Query>),
|
||||||
|
@ -127,6 +128,14 @@ pub mod query_parser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn has_attachment<'a>() -> impl Parser<'a, Query> {
|
||||||
|
move |input| {
|
||||||
|
whitespace_wrap(match_literal_anycase("has:attachment"))
|
||||||
|
.map(|()| Query::HasAttachment)
|
||||||
|
.parse(input)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn literal<'a>() -> impl Parser<'a, String> {
|
fn literal<'a>() -> impl Parser<'a, String> {
|
||||||
move |input| either(quoted_string(), string()).parse(input)
|
move |input| either(quoted_string(), string()).parse(input)
|
||||||
}
|
}
|
||||||
|
@ -196,6 +205,7 @@ pub mod query_parser {
|
||||||
.or(bcc().parse(input))
|
.or(bcc().parse(input))
|
||||||
.or(subject().parse(input))
|
.or(subject().parse(input))
|
||||||
.or(flags().parse(input))
|
.or(flags().parse(input))
|
||||||
|
.or(has_attachment().parse(input))
|
||||||
{
|
{
|
||||||
Ok(q)
|
Ok(q)
|
||||||
} else if let Ok((rest, query_a)) = not().parse(input) {
|
} else if let Ok((rest, query_a)) = not().parse(input) {
|
||||||
|
|
|
@ -461,6 +461,9 @@ pub fn query_to_sql(q: &Query) -> String {
|
||||||
s.push_str(") ");
|
s.push_str(") ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
HasAttachment => {
|
||||||
|
s.push_str("has_attachments == 1 ");
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue