I'm in a situation where I need to span Google App Engine entity relationships in a query like in the Django database model. I'm using ListProperty
s for one-to-many relationships, like so:
class Foo(db.Model): bars = db.ListProperty(db.Key)
class Bar(db.Model): eggs = db.ListProperty(db.Key)
And I'd like to perform a query that does the following:
# Foo.filter('bars.eggs =', target_egg)
[foo
for egg in eggs if egg == target_egg
for eggs in bar.eggs
for bar in foo.bars
for foo in Foo.all()]
The comprehension seems radically inefficient. I'd really like to perform a query as in the commented out portion, but it doesn't look like the GQL syntax allows for queries against the attributes of attributes:
SELECT * FROM <kind>
[WHERE <condition> [AND <condition> ...]]
[ORDER BY <property> [ASC | DESC] [, <property> [ASC | DESC] ...]]
[LIMIT [<offset>,]<count>]
[OFFSET <offset>]
<condition> := <property> {< | <= | > | >= | = | != } <value>
<condition> := <property> IN <list>
<condition> := ANCESTOR IS <entity or key>