Micro
Micro

Reputation: 10891

objectify v6 - NOT and IN filters no longer supported? Alternatives?

The objectify v6 docs say:

NOT and IN filters are not supported by the new SDK. You will get a runtime error if you try to ofy().load().type(Thing.class).filter("field !=", value) or filter("field IN" values).

Even if in objectify v5, should we stay away from using NOT or IN filters as they are, it looks like, on the way out?

Is there anymore information on why these are no longer supported? Any alternative methods to maybe achieve a similar type of query? Specifically, the IN query. Which is/was pretty useful if you have say a list of user id's that you need to query all of something of.

Upvotes: 1

Views: 525

Answers (1)

Alex
Alex

Reputation: 5276

Those were just convenience filters anyway that got translated into a composition of other filters.

The != (not-equal) and IN (membership) operations are implemented by combining other filters using the OR operation. The first of these,

https://cloud.google.com/appengine/docs/standard/python/ndb/queries#neq_and_in

property != value is implemented as (property < value) OR (property > value)

property IN [value1, value2, ...] is implemented as (property == value1) OR (property == value2) OR ...

So you could just convert all your != and IN filters to that

Upvotes: 2

Related Questions