GQL test for null IntegerProperty

I am trying to query records in the Google App engine, where IntegerProperty is null (None). This is what I tried without success:

data = db.GqlQuery("SELECT * FROM MyModel WHERE intProp=:1",None)

And also with the request:

query = db.Query(MyModel)
query = query.filter('intProp', None) 
data = query.fetch(limit=100)

Any help would be appreciated.

class MyModel(db.Model):
    intProp = db.IntegerProperty()
+3
source share
2 answers

Your code looks correct. Do you actually have instances MyModelwith intPropfrom None...?

Edit : to OP's comment this is apparently a schema migration problem; he added a new property and expected existing objects to appear (set to None). This is not how the schema changes in the work of GAE, behind the docs :

App Engine , . , . , , . , ? . , , " " " ", , . , .

, , , , , GAE , apis .. . App Engine Fan post, ( , , !) API ; ( Riteveld , Guido van Rossum, Python App Engine), ( , , , Rietveld).

+4

NULL-, , :

SELECT * FROM MyModel WHERE intProp < 0

, , .

+2

Source: https://habr.com/ru/post/1715674/


All Articles