It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Brackets removed after saving Query Filter

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
Warren Community Leader Oct 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.

0 votes

@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

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

I love this :) brings back memories.

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

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

@Ravi Sagar -Adaptavist- 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!

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
Payne Community Leader Oct 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)

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

303 views 1 3
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you