3

我从移植谷歌应用程序引擎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使用卡桑德拉作为数据存储。这是App Engine数据存储和Cassandra之间行为的细微差别吗?

回答

3

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

+1

是的,这是固定的。谢谢 – 2014-11-04 15:06:26