Order of Operations for JQL
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Summary
When using JQL for Issue Filters/Queues/SLAs/Automation, sometimes unwanted issues are returned by the query unexpectedly. Why does this happen? How can we optimize these queries and ensure incorrect Issues 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.
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, more issues can be returned when using the OR
statement, causing incorrect results where JQL is being 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 comparison ( |
|
Solution
When configuring any JQL query anywhere within your site it is important to keep this order of operations in mind in order to avoid incorrect issues being picked up by the query, regardless of the configuration.