Kex
Kex

Reputation: 776

GqlQuery from GoogleAppEngine returns empty list

Here is my query:

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

Here is my model:

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

When I execute the query in the GoogleAppEngine Data Viewer, I get the results: enter image description here

What am I missing?

Upvotes: 0

Views: 986

Answers (1)

systempuntoout
systempuntoout

Reputation: 74134

The following code with your GqlQuery statements works for me.

    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))

It returns:

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

Upvotes: 1

Related Questions