Search code examples
google-app-enginegql

I need a query in GAE that return rows that don't contain null, means that are fulfilled


SELECT * FROM Feedback WHERE text =! None

Nul, doesn't work either.

It doesn't work... So how should I write this query?


Solution

  • From GAE documentation: It is not possible to query for entities that are missing a given property. One alternative is to create a fixed (modeled) property with a default value of None, then create a filter for entities with None as the property value.

    You could achieve the same results by:

    def notnulls():
           return [z for z in db.GqlQuery('SELECT * FROM Feedback') if z.text]
    

    This will return a list of Feedback objects where the text field is not None. Although this does have the extra overhead of loading all Feedback objects first.