Saket Bansal
Saket Bansal

Reputation: 156

GAE DataStore : Any example of using executeWithArray

I am trying to apply more than three filter criteria on Query. I came to know that this is possible using executeWithArray. Can someone share example of it? I need to apply more than three filters involving different columns.

Upvotes: 1

Views: 391

Answers (2)

Saket Bansal
Saket Bansal

Reputation: 156

I am able to apply more than three filter in query if I make filter string using the direct criteria:

Example: I added isClosed=='N' criteria directly in the filter string.

query.setFilter("trackerId == trackerParam && projectId == projParam && 
    codeListIds.contains(filId) && isClosed=='N'");

Still, Query can max three parameters only:

query.declareParameters("Long trackerParam,Long projParam,Long filId");

Upvotes: 0

mgiuca
mgiuca

Reputation: 21357

Assuming you are using Java. There are a lot of examples on the Queries and Indexes page, and it explains the restrictions involving the different filters (under "Restrictions on Queries"). A quick summary:

  • Most likely, the issue is that you can only have an inequality filter on one column. You can do an "=" filter on as many columns as you like, but you can only do "!=", "<", "<=", ">" or ">=" on a single column in one query.
  • If you have an inequality filter, and are also sorting the output, you need to sort first on the column used in the inequality filter.
  • If you are using transactions, all queries must be "ancestor queries" -- you must restrict the query to only entities with a certain parent.

Upvotes: 1

Related Questions