impl fromstr for query
parent
8e71e34a09
commit
7d0b23e955
|
@ -234,6 +234,15 @@ impl TryFrom<&lexpr::Value> for Query {
|
|||
}
|
||||
}
|
||||
|
||||
impl FromStr for Query {
|
||||
type Err = anyhow::Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let sexp = lexpr::from_str(s)?;
|
||||
Query::try_from(&sexp)
|
||||
}
|
||||
}
|
||||
|
||||
impl Query {
|
||||
pub(crate) fn to_sqlite_predicates(&self) -> Result<Box<Predicate>> {
|
||||
match self {
|
||||
|
|
|
@ -89,8 +89,7 @@ pub async fn get_query(
|
|||
) -> Result<HttpResponse, Error> {
|
||||
let connection = state.db_pool.get().map_err(ErrorInternalServerError)?;
|
||||
|
||||
let sexp = lexpr::from_str(info.query.as_str()).map_err(ErrorBadRequest)?;
|
||||
let in_query = Query::try_from(&sexp).map_err(ErrorBadRequest)?;
|
||||
let in_query: Query = info.query.as_str().parse().map_err(ErrorBadRequest)?;
|
||||
let entries = query(&connection, in_query).map_err(ErrorInternalServerError)?;
|
||||
let mut result: HashMap<String, Entry> = HashMap::new();
|
||||
for entry in entries {
|
||||
|
|
Loading…
Reference in New Issue