Don't use in, just use equal:
q = db.GqlQuery("SELECT * FROM DummyData where x = 'c' and x = 'a'")

And you can read this document:
http://code.google.com/intl/zh-CN/appengine/docs/python/datastore/entitiesandmodels.html#Lists
2009/4/19 ecognium <ecogn...@gmail.com>

>
> Hello everyone, I noticed an odd behavior with GQL query when it has
> two IN operators and a regular condition. Below is some basic code to
> reproduce the problem:
>
>
> class DummyData(db.Model):
>        x = db.StringListProperty()
>        y = db.TextProperty()
>
> class Dummy(webapp.RequestHandler):
>    def get(self):
>        d = DummyData()
>        d.x = ['a', 'b','c']
>        d.y = "test"
>        d.put()
>        d = DummyData()
>        d.x = ['c', 'd','e']
>        d.y = "test2"
>        d.put()
>
>        q = db.GqlQuery("SELECT * FROM DummyData where x in ('c') and
> x in ('a') ")
>        results = q.fetch(10) # 10 instead of 2? - useful if you run
> the test multiple times
>        for r in results:
>            self.response.headers['Content-Type'] = "text/plain"
>            self.response.out.write("x = " + ",".join(r.x) + " y = " +
> r.y + "\n")
>
> When you run the above code you will see the following output:
> x = a,b,c y = test
>
> However when I replace the above query with the one below, I do not
> get any  results (even though it should return the same result as
> above):
>
> # Note the addition of y = 'test'
> q = db.GqlQuery("SELECT * FROM DummyData where y = 'test' and x in
> ('c') and x in ('a') ")
>
> Although here the IN conditions are the same as '=', my application
> actually uses multiple list values.; I am just presenting a simpler
> example.
>
> If someone can confirm the issue, I can open a bug report for this.
>
> Thanks!
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to