in gql, how do i sort by a field in another class linked by referenceproperty?
for example, 2 classes in a 1-to-many relationship:
class owner(db.model):
name = db.StringProperty()
class cat(db.model):
name开发者_StackOverflow中文版 = db.StringProperty()
owner = db.ReferenceProperty(owner)
so how do i produce a list of cats ordered by owner.name (then optionally by cat.name)?
i tried "SELECT * FROM cat ORDER BY owner.name" but got Parse Error: Expected no additional symbols at symbol .name
Thanks
You can't; this would require a join, which the datastore doesn't support. If you need to sort like this, denormalize your data and include the owner name in the cat model.
精彩评论