Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AppEngine: Query datastore for records with <missing> value

Tags:

I created a new property for my db model in the Google App Engine Datastore.

Old:

class Logo(db.Model):   name = db.StringProperty()   image = db.BlobProperty() 

New:

class Logo(db.Model):   name = db.StringProperty()   image = db.BlobProperty()   is_approved = db.BooleanProperty(default=False) 

How to query for the Logo records, which to not have the 'is_approved' value set? I tried

logos.filter("is_approved = ", None) 

but it didn't work. In the Data Viewer the new field values are displayed as .

like image 914
Federico Elles Avatar asked Feb 28 '09 20:02

Federico Elles


1 Answers

According to the App Engine documentation on Queries and Indexes, there is a distinction between entities that have no value for a property, and those that have a null value for it; and "Entities Without a Filtered Property Are Never Returned by a Query." So it is not possible to write a query for these old records.

A useful article is Updating Your Model's Schema, which says that the only currently-supported way to find entities missing some property is to examine all of them. The article has example code showing how to cycle through a large set of entities and update them.

like image 174
maxg Avatar answered Sep 27 '22 23:09

maxg