Brackets removed after saving Query Filter

Swaroop Rao October 15, 2019

I'm trying to use a JQL Query Filter to display subtasks for specific users in my Scrum Board. For tasks I want to look at the 'Assignee' field but for stories, I want to refer to the 'QA' field (which is a custom field). So, I'm creating a query like:

project = DEV AND ((type = Story AND QA = user1) OR (type in (Defect, Development, QA, Sub-task) AND assignee = user1)).

I save the query and I see some results but they don't look right so I try to go back to the query filter and see the query. I see that it has been changed to:

project = DEV AND (type = Story AND QA = user1 OR type in (Defect, Development, QA, Sub-task) AND assignee = user1)

You will notice that JIRA has removed one pair of outer brackets. So, a query like ((A AND B) OR (C AND D)) is being changed to A AND B OR C AND D. I'll have to write out the truth table to confirm but I believe that these two queries will not produce the same results. Can somebody from Atlassian please review this and respond?

4 answers

0 votes
Payne
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.
October 15, 2019

The best I can tell, Jira JQL gives precedence to AND over OR, so that

A AND B OR C AND D

is equivalent to

(A AND B) OR (C AND D)

0 votes
Swaroop Rao October 15, 2019

I created the truth table for both queries and I DO see differences in the results. I'm pasting a screenshot of the truth table. Unless there's something else I'm missing here, I think Atlassian should review this functionality and ensure that it preserves the brackets exactly as the user specified them.Screen Shot 2019-10-15 at 12.05.22 PM.png

Ravi Sagar _Sparxsys_
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.
October 15, 2019

I love this :) brings back memories.

Anyways for without parenthesis column what is your operator precedence - left to right or right to left?

Swaroop Rao October 15, 2019

Actually, I found a bug in my Excel formula. I have redone the calculation and still see a mismatch. I'm pasting a new screenshot below for this.

In Excel, I used the following formula to simulate the L-to-R computation that Atlassian uses. 

=AND(D2,OR(C2,AND(A2,B2)))

Screen Shot 2019-10-15 at 12.24.33 PM.png

Swaroop Rao October 15, 2019

@Ravi Sagar _Sparxsys_ you think it brings back memories? Imagine my plight...I graduated from college more than 30 years ago! I'm too old to even remember when I learned truth tables! Probably around 1985 or 1986!

Ravi Sagar _Sparxsys_
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.
October 15, 2019

Yeah I am not old :p

If results are inconsistent then try creating a filter for sub queries. 

The Atlassian documentation says L to R but your truth table says something else. I guess the parentheses are still respected (at least in most cases). 

0 votes
Ravi Sagar _Sparxsys_
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.
October 15, 2019

@Swaroop Rao 

You can follow this issue: https://jira.atlassian.com/browse/JRASERVER-39107

The results should not vary though but Jira does remove nested parenthesis. It is annoying to read your own JQL after few weeks and understand the logic.

Try creating filters for your sub queries and use it in the JQL like filter = "filter 1" AND filter = "filter 2". It will improve the readability.

Ravi

0 votes
Warren
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.
October 15, 2019

Hi @Swaroop Rao 

If you want someone from Atlassian to review this, you may need to raise a support ticket, but i would probably confirm via a truth table that it isn't working first.

My question is - if you have the query set up, with all brackets as you want them, before saving, what happens if you run the query? Do you get the expected results? Or does it automatically remove brackets, even without saving?

I tried a query with the same structure of brackets and ANDs and ORs, but prior to saving it ran and didn't remove brackets (returned 2471 rows). I then saved it and it removed both sets of inner brackets, but still returned 2471 rows.

Suggest an answer

Log in or Sign up to answer