来自GoogleAppEngine的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的数据查看器中执行这个查询时,我得到了这些结果:

我漏掉了什么呢?
1 个回答
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