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:

  1. Parentheses ()
  2. Comparison (=, !=, >=, IS, IS NOT, IN, NOT IN, ~, !~, ...)
  3. Negation (NOT)
  4. AND
  5. 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 AND statement, then the OR statement

(status=resolved AND project=SysAdmin) OR assignee=bobsmith

This query will also evaluate from left to right, where the NOT IN statements take precedence, then the AND statement

reporter NOT IN (Jack,Jill,John) AND assignee NOT IN (Jack,Jill,John)


This query is evaluated from the comparisons first (< and IS), then the OR statement

duedate < now() OR duedate IS EMPTY

This query evaluates the parentheses first, then comparison (=), then the OR statement, then the negation (NOT)

NOT (reporter = jsmith or reporter = jbrown)

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.

Relevant Documentation

Last modified on Dec 25, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.