REST orQueries logic

I find the orQueries logic in the /task API hard to comprehend and very limiting in expression power. Given the example used in the doc:

  "assignee": "John Munda",
  "orQueries": [
      "name": "Approve Invoice",
      "priority": 5
      "suspended": false,
      "taskDefinitionKey": "approveInvoice"

I had expected it would to be translated into an SQL where clause like:

where asignee='John Munda' and ((name='Approve Invoice' and priority=5) or (suspended=false and taskDefinitionKey='approveInvoice'))

But I was perplexed to find it actually turned into:

where asignee='John Munda' and (name='Approve Invoice' or priority=5) and (suspended=false or taskDefinitionKey='approveInvoice')

With this kind of transformation, I can not find a proper expression for some of my intentions. For instances, I’d like to get a list of all tasks with defintion key A or B which are due date within 3 days AND all overdue tasks. That is, I’d like the the final SQL where clause to look like:

where (taskDefinitionKey in ['A', 'B'] and due < now + 3days) or due < now

How shall I write my query for this purpose?

I think to be make more flexible task queries, we need a top-level OR query in stead of a top-level AND.

1 Like

@Niall any insight on the usage here? I had run into this recently, and also trying to make sense of the example in the docs, as the example seems to make no sense for the usage…

Hi @StephenOTT
Thanks for bringing this up - i’ll ask someone to look into this.

Hey @StephenOTT,

it is actually as described by @Yuan_HOng.
You can, as of now, define blocks of attributes that shall be combined by OR, whereas all those OR blocks are combined by AND.

That is resembling the capabilities of the Java API of the TaskQuery.
That API is still limited to certain scenarios and as far as I can tell, it will not yet be powerful enough to allow arbitrary combinations and nestings of AND and OR blocks. That would however be necessary in order to allow to create the example that was given above.

We are of course open to feature requests and contributions in the form of pull requests on that topic.


What is the use case for the current capability with the orQueries? What common use case is being solved?

It would seem there needs to be a flag to make the OrQueries do OR between each object in the array, and treat each property in each object as a AND.