fix(client): correct not-equal date filter in status query
When filtering `pueue status` with a bare date and the `!=` operator (e.g. `end!=2022-01-10`), the generated predicate was `field < start_of_day && field > end_of_day`. A timestamp can never be both before the start and after the end of the same day, so the filter always evaluated to false and silently dropped every task. Use `||` so a task matches when its timestamp lies outside the given day, mirroring the `lt`/`gt` branches for the same column.
This commit is contained in:
1 parent
eb9a320061
commit
cb4c18b107
2 files changed
+16
-1
No files matched your search
@@ -169,7 +169,7 @@ pub fn datetime(section: Pair<'_, Rule>, query_result: &mut QueryResult) -> Resu
|
||||
|
||||
match operator {
|
||||
Rule::eq => field > start_of_day && field < end_of_day,
|
||||
Rule::neq => field < start_of_day && field > end_of_day,
|
||||
Rule::neq => field < start_of_day || field > end_of_day,
|
||||
Rule::lt => field < start_of_day,
|
||||
Rule::gt => field > end_of_day,
|
||||
_ => true,
|
||||
|
||||
@@ -384,6 +384,21 @@ mod test {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Filter by end date using the not-equal operator.
|
||||
/// A `column != date` filter must keep every task whose end lies outside of that day.
|
||||
#[rstest]
|
||||
#[case("2022-01-10", 1)]
|
||||
#[case("2022-01-08", 0)]
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn filter_end_neq_date(#[case] date: &str, #[case] expected_id: usize) -> Result<()> {
|
||||
let tasks = test_tasks_with_query(&format!("end!={date}"), &None)?;
|
||||
|
||||
assert_eq!(tasks.len(), 1);
|
||||
assert_eq!(tasks[0].id, expected_id);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Filter tasks by status
|
||||
#[rstest]
|
||||
#[case("queued", 2)]
|
||||
|
||||
Reference in new issue
Block a user