开发者

Google app engine: empty property in datastore

开发者 https://www.devze.com 2022-12-31 11:03 出处:网络
Let say I have a model: class A(db.Model): B = db.StringProperty() C = db.StringProperty() How do I query if I wanted to search all 开发者_开发知识库empty property (not None, just empty) in C using

Let say I have a model:

class A(db.Model):
    B = db.StringProperty()
    C = db.StringProperty()

How do I query if I wanted to search all 开发者_开发知识库empty property (not None, just empty) in C using python?


From GAE Python documents

It is not possible to perform a 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.


Well if you want to return all rows with empty C properties you could do this.

empty = db.GqlQuery('SELECT * FROM A WHERE C = ""')

0

精彩评论

暂无评论...
验证码 换一张
取 消