0

这是我的查询:

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 数据查看器中执行查询时,我得到了结果: 在此处输入图像描述

我错过了什么?

4

1 回答 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
于 2011-09-19T18:49:58.317 回答