Return an error when calling DELETE /tasks with an empty query

This commit is contained in:
Loïc Lecrenier 2022-10-15 11:17:06 +02:00 committed by Clément Renault
parent 9067148270
commit dabc30d3d6
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
4 changed files with 28 additions and 1 deletions

View file

@ -56,6 +56,21 @@ impl Default for Query {
}
impl Query {
/// Return `true` iff every field of the query is set to `None`, such that the query
/// would match all tasks.
pub fn is_empty(&self) -> bool {
matches!(
self,
Query {
limit: None,
from: None,
status: None,
kind: None,
index_uid: None,
uid: None
}
)
}
pub fn with_status(self, status: Status) -> Self {
let mut status_vec = self.status.unwrap_or_default();
status_vec.push(status);