I’m trying to build a forum like platform on GAE.
I must mention first: I’m a bit new to GAE.
I want to pull all replies to a specific post.
So far the structure looks like so:
- Forum
--- Post
----- Reply ( = Post with Post as a parent )
Replies are just posts with post as their parent(instead of the forum as a parent).
The problem begins when I try to pull out all of the replies, the returned results include the ancestor itself.
How can I achieve the same without the ancestor itself?(Might need to mention also that I searched for a solution but haven’t found one)
Edit:
My query is like so:
replies = db.GqlQuery("SELECT * FROM Post WHERE ANCESTOR IS :1", post)
Thanks!
Update:
Well I’ve found a way:
db.GqlQuery("SELECT * FROM Post WHERE ANCESTOR IS :1 AND __key__ != :2", post, post.key())
just query and rule out the ancestor itself in the where clause!
Your proposed solution uses an inequality filter in the query. Inequality filters aren’t supported by the underlying datastore, and are internally translated into two separate queries, like so:
Obviously, this is substantially less efficient. A much simpler and more efficient option is to simply fetch all results, then discard the one entity that you don’t want.