Jira Cloud JQL: Understanding Query Order of Operations
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
When using JQL for Work Item Filters/Queues/SLAs/Automation, sometimes the query unexpectedly returns unwanted work items. Why does this happen? How can we optimize these queries and ensure that incorrect work items are not returned?
The first thing we need to understand is the order of operations for Jira Query Language and how keywords and operators are prioritized in a query.
Solution
Cause - Order of Operations
Please see the full list of operators and statements listed from strongest binding to the weakest:
Parentheses ()
Comparison (=, !=, >=, IS, IS NOT, IN, NOT IN, ~, !~, ...)
Negation (NOT)
AND
OR
For example, the AND
statement has a stronger binding than the OR
statement, meaning the query will have a more refined search than the OR
statement. In this scenario, the OR
statement can return more work items, causing incorrect results when JQL is used.
Example Queries
This query is evaluated from left to right, where the parentheses take precedence, then the |
|
This query will also evaluate from left to right, where the |
|
This query is evaluated from the comparisons first ( |
|
This query evaluates the parentheses first, then the comparison ( |
|
Next Step(s)
When configuring any JQL query anywhere within your site, it is important to keep this order of operations in mind to avoid incorrect work items being picked up by the query, regardless of the configuration.
Relevant Documentation
Was this helpful?