0

这里是我的查询:GqlQuery返回空列表

currentID = 7 
deck = range(0,3) 
similarIDs = db.GqlQuery('SELECT * FROM itemSet WHERE jokeID=:1 AND position IN :2', currentID, deck[:3]).fetch(100) 

这里是我的模型:

class itemSet(db.Model): 
jokeID = db.IntegerProperty() 
jokeID2 = db.IntegerProperty() 
position = db.IntegerProperty() 

当我执行的GoogleAppEngine数据浏览查询,我得到的结果: enter image description here

我缺少什么?

+0

问题出在哪里? – systempuntoout

+0

当我similarIDs执行上面的代码中,我得到表3个空元素,'[,,]',我需要得到相同的结果作为GAE数据查看器.. – Kex

+0

告诉我们,处理的结果代码查询。我有一个非常类似的查询我的应用程序之一,并按预期工作。 –

回答

1

下面的代码与你的GqlQuery声明对我的作品。

item = itemSet() 
    item.jokeID = 7 
    item.jokeID2 = 1 
    item.position = 0 
    item.put() 
    item = itemSet() 
    item.jokeID = 7 
    item.jokeID2 = 2 
    item.position = 1 
    item.put() 

    currentID = 7 
    deck = range(0,3) 
    similarIDs = db.GqlQuery('SELECT * FROM itemSet \ 
          WHERE jokeID=:1 AND position IN :2' 
          , currentID, deck[:3]).fetch(100) 
    for item in similarIDs: 
     logging.info("%s : %s" % (item.jokeID, item.position)) 

它返回:

INFO  2011-09-19 18:46:28,299 main.py:47] 7 : 0 
INFO  2011-09-19 18:46:28,299 main.py:47] 7 : 1 
+0

的确.. 我的错误是在我的HTML文件中的Python代码。 – Kex