Skip to content

Commit

Permalink
lib: bugzilla search: don't use logical AND for id params for regular…
Browse files Browse the repository at this point in the history
… values

Since bug IDs are unique identifiers so queries trying to match a single
bug against multiple IDs makes no sense.

This fixes queries trying to match against a list of ID values when
piped from stdin using `bite`.
  • Loading branch information
radhermit committed Sep 21, 2024
1 parent 8b33503 commit 6942e70
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions crates/cli/doc/bite-bugzilla-search.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,9 @@ Values can use the `-` prefix to search for identifiers not equal to the value.
.Not equal to 10:
bite bugzilla search --id=-10
+
Multiple values can be specified in a comma-separated list for logical AND or
multiple options for logical OR.
Multiple values can be specified in a comma-separated list or multiple options.
If any ID range is specified logical AND is used, otherwise values are combined
via logical OR.
+
.IDs greater than 10 and less than 20:
bite bugzilla search --id '>10,<20'
Expand Down
7 changes: 6 additions & 1 deletion crates/lib/src/service/bugzilla/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,12 @@ impl Request {
match value {
ExistsOrValues::Exists(value) => query.exists("bug_id", *value),
ExistsOrValues::Values(values) => {
query.and(|query| values.iter().for_each(|x| query.ids(x)))
// only use logical AND when values contain ID ranges
if values.iter().all(|x| matches!(x, RangeOrValue::Value(_))) {
values.iter().for_each(|x| query.ids(x));
} else {
query.and(|query| values.iter().for_each(|x| query.ids(x)));
}
}
}
}
Expand Down

0 comments on commit 6942e70

Please sign in to comment.