views:

41

answers:

1

Can anyone share your approach for doing a 'or' query in app-engine?

Let say I have

class A_db_model(db.Model):
 valueA = db.ListProperty(basestring)

in valueA I have

aaa
aaa, bbb
bbb
ccc

I would like to return result of if the valueA match 'aaa' or 'bbb' and return not duplicated result.

+5  A: 

Try this?

A_db_model.all().filter('valueA IN', ['aaa', 'bbb'])

or the equivalent GQL:

GqlQuery('SELECT * FROM A_db_model WHERE valueA IN :1', ['aaa', 'bbb'])
Amber
thanks it work ...
Pete
Note that the datastore can't actually do this kind of query; this syntax results in 2 queries being done and the results merged. Using long lists of values for the IN condition is a Bad Idea.
Wooble
Yep. In fact, due to how list properties work, you wind up doing `NxM` comparisons in `N` queries.
Amber