Search code examples
godatastore

Does datastore supports inequality filter?


I'm trying to run a query using the inequality filter but it errors out:datastore: invalid operator "!=" in filter "Field1 !=" Isn't this supported?

I'm using Go whose documentation doesn't mention this filter but the python docs seem to support negation so I'm wondering if it's a go specific issue or if I'm missing something.

q.Query = q.Query.Filter("Field1 !=", value)

Solution

  • In the doc, it states that filter only supports these: =, <, <=, >, >=.

    So != isn't supported. However you may have a workaround like this:

    q.Query = q.Query.Filter("Field1 >", value).Filter("Field1 <", value)
    

    which should yield the result as !=.