Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JIRA Query > Missing items where component is Empty

Adam Youngers
Contributor
January 11, 2022

I'm running into a query problem that I feel is a bug in JIRA's query language, but I am hoping I am wrong.  Given the below query, the first line builds up a list and the 2nd should be filtering it down, which it does, but not as designed.

(filter = 23266 OR project in (WD, WC)) AND NOT
(component in (PBE) AND assignee is EMPTY)
ORDER BY Rank

My expectation for the above is that 2nd line would remove items found in the first line where the component is PBE and the assignee is EMPTY.  It does this, but it is also removing items where the component is EMPTY and the assignee is EMPTY.  Why?

UPDATE

Although I'm not entirely satisfied with the solution, it turns out this was an issue with my understanding of the use of NOT.  The solution involved asking for everything I wanted instead of asking to leave out the one thing I didn't want. Makes for a pretty ugly query. Is a shame JQL does not handle this situation better.

(filter = 23266 OR project in (WD, WC)) AND (
  (component is EMPTY AND assignee is EMPTY) OR
  (component is EMPTY and assignee is not EMPTY) OR
  (component != PBE AND assignee is not EMPTY) OR
  (component != PBE AND assignee is EMPTY) OR
  (component = PBE AND assignee is not EMPTY)
) ORDER BY Rank

1 answer

1 accepted

0 votes
Answer accepted
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 11, 2022

It's a quirk of logic that humans find counter-intuitive, but when a multi-select field has nothing to work with when you say "field has X", it does not match.  Null is not something you can compare with a value.

When you say "component in PBE", that clause ignores all empty components, because there is nothing for it to compare PBE with.

Try:

(component in (PBE) or component is empty) AND assignee is EMPTY

Adam Youngers
Contributor
January 11, 2022

I tried this:

(filter = 23266 OR project in (WD, WC)) AND NOT
((component in (PBE) or component is empty) AND assignee is EMPTY)
ORDER BY Rank

And I'm getting the same issue.

Adam Youngers
Contributor
January 11, 2022

The above actually makes sense based on the result I'm getting back as it is saying take line 1 and remove anything where the assignee is empty and the component is empty or set to PBE.  

I want the ones where assignee is empty and component is empty to remain, not be pulled out.

Adam Youngers
Contributor
January 11, 2022

The only "Hack" workaround I can think of currently is to remove the null case from the mix and require a Component set.  Possibly setting something up in automation to populate it.  But also, gross.

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 12, 2022

Ok, I think I misunderstood the question that you're trying to ask.

"Not" is quite a difficult thing for humans to process, and they can make building queries a lot harder to construct and read.  Ideally, use them sparingly

Don't think about "taking away from another line" when you're building queries, always start with "how do I select what I want to see".

Having re-read your comments, I think it might be worth rephrasing the question, and hence the JQL.

I think you could break down your query into:

  • The easy bit that doesn't need any attention: (filter = 23266 OR project in (WD, WC))
  • And the assignee is empty
  • And then please exclude issues with a component of PBE or not having a component at all

If that is the right question, then, the query becomes more intuitive:

(filter = 23266 OR project in (WD, WC)) and assignee is empty and not (component = PBE or component is empty)

I know that'll give the result for the question I've just re-written, but have I rephrased the question correctly now?

Adam Youngers
Contributor
January 14, 2022

No I don't think you have.  Here is what I want:

  • I want everything from (filter = 23266 OR project in (WD, WC)), but: 
    • I do NOT want the ones where assignee is empty and component is PBE.
    • I do want the ones where assignee is empty and component is empty.
    • I do want the ones where assignee is set and component is PBE.
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 15, 2022

Ok, great, having it spelt out makes it easy to understand, and it's simple to get rid of the "not", making it the resulting query easier to understand.  For this one, you can just forget the "I don't want" by just not selecting for it.

Try 

(filter = 23266 OR project in (WD, WC)) And ( (assignee is empty and component is empty) or (assignee is not empty and component = PBE) )

Adam Youngers
Contributor
January 21, 2022

Thanks for the help on this Nic.  The above solution is still not quite right.  It misses items where the component is something other than PBE and the assignee is not empty. 

Adam Youngers
Contributor
January 21, 2022

So this illustrates what I'm going for.  I think there is an answer here based on your solution. 

Untitled_spreadsheet_-_Google_Sheets.png

Adam Youngers
Contributor
January 21, 2022

@Nic Brough -Adaptavist-  - So I think I have a modified solution based on yours and the grid above.  It's not pretty, but it does do what I was looking for:

(filter = 23266 OR project in (WD, WC)) AND (
  (component is EMPTY AND assignee is EMPTY) OR
  (component is EMPTY and assignee is not EMPTY) OR
  (component != PBE AND assignee is not EMPTY) OR
  (component != PBE AND assignee is EMPTY) OR
  (component = PBE AND assignee is not EMPTY)
) ORDER BY Rank

It for sure feels like more than would be necessary for such a thing.  It's a shame JQL does not support filtering the results of another query.  

Suggest an answer

Log in or Sign up to answer