Error in or operator for query in GAE datastore

115 views Asked by At

I have a table in Google app engine datastore. It has 3 columns A,B and C. I need to retrieve all the rows that contain val in either column A, B or C. I am writing a standard sql query like select * from table where A = val or B = val or C = val. But it gives an error. Is there any work around for this? I am using python

1

There are 1 answers

0
Tim Hoffman On

GQL is not SQL and does not support OR. See docs https://developers.google.com/appengine/docs/python/datastore/gqlreference

You can do such a query using the Query object, e.g.

query = SomeModel.query().filter(
      ndb.OR(SomeModel.A == val,
           SomeModel.B == val, 
           SomeModel.C == val)
      )