AppEngine:查询具有<缺失>记录的数据存储值 [英] AppEngine: Query datastore for records with <missing> value

查看:82
本文介绍了AppEngine:查询具有<缺失>记录的数据存储值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Google App Engine Datastore中为我的db模型创建了一个新属性。



旧:

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



模型):
name = db.StringProperty()
image = db.BlobProperty()
is_approved = db.BooleanProperty(default = False)

如何查询未设置'is_approved'值的Logo记录?
我试过

  logos.filter(is_approved =,无)

但它不起作用。
在数据查看器中,新字段值显示为。

解决方案

根据查询和索引,实体之间有一个区别, em> no 值,以及那些具有 null 值的值;和没有筛选属性的实体永远不会被查询返回。因此,无法为这些旧记录编写查询。



有用的文章是更新你的模型的模式,它表示目前唯一支持的方式来查找缺少某些属性的实体,以便检查所有这些属性。这篇文章有示例代码,展示了如何循环一大组实体并更新它们。


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 .

解决方案

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.

这篇关于AppEngine:查询具有<缺失>记录的数据存储值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆