【问题标题】:Non-root entity group queries returning zero results返回零结果的非根实体组查询
【发布时间】:2014-11-04 02:23:00
【问题描述】:

我正在将应用程序从 Google App Engine 移植到 AppScale,并且在对实体组执行祖先查询时发现了异常行为。

如果我在父不是根的情况下执行祖先查询,则查询返回零结果。如果我将父级作为 root 执行相同的查询,则会返回正确的结果。

举个例子最容易说明:

class A(ndb.Model):
  name = ndb.StringProperty()

class B(ndb.Model):
  name = ndb.StringProperty()

class C(ndb.Model):
  name = ndb.StringProperty()
  active = ndb.BooleanProperty()
  sort = ndb.IntegerProperty()

def main():
  a = A(name='I am A')
  a.put()

  b = B(parent=a.key,
        name='I am B')
  b.put()

  C(parent=b.key,
    name='I am C1',
    active=True,
    sort=0).put()

  C(parent=b.key,
    name='I am C2',
    active=True,
    sort=1).put()

  C(parent=b.key,
    name='I am C3',
    active=True,
    sort=2).put()

  query1 = C.query(C.active == True, ancestor=a.key).order(C.sort).fetch(10)
  query2 = C.query(C.active == True, ancestor=b.key).order(C.sort).fetch(10)

  print 'query 1 = %s' % len(query1)
  print 'query 2 = %s' % len(query2)

如果我在 App Engine 上运行上述代码,我会为这两个查询得到 3 个结果。如果我在 AppScale 上运行它,那么第一个查询只得到 3 个结果,第二个查询只得到 0 个结果。

AppScale 使用 Cassandra 作为数据存储。这是 App Engine 数据存储区和 Cassandra 之间行为的细微差别吗?

【问题讨论】:

    标签: google-app-engine cassandra google-cloud-datastore appscale nosql


    【解决方案1】:

    这是 AppScale 中的一个错误,我们使用了提供的祖先的完整路径,而不仅仅是它的根实体进行复合查询。它的修复可以在这里找到: https://github.com/AppScale/appscale/pull/1633

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-09
      • 1970-01-01
      • 2020-07-07
      • 2016-02-08
      • 2013-04-29
      • 2018-06-16
      • 1970-01-01
      相关资源
      最近更新 更多