I have the following models:
class Author(db.Model):
name = db.StringProperty()
class Story(db.Model):
author = db.ReferenceProperty(Author)
What’s the raw GQL to find all Stories by a certain author. In regular SQL, I will use joins but I don’t think that’s available in GQL.
Edit:
I’m looking for the raw GQL way, I know how to do it the Pythonic way. For instance something like(the following is probably totally wrong):
"SELECT * FROM Story WHERE author = :1", "Shakespeare"
I want to run the above from the GAE admin Data > Data Viewer > Query the Datastore. I want the raw SQL that someone could run from a typical mysql or psql shell.
Edit2: Ah, the raw-GQL for use in the data-viewer…
Here’s one way:
1) Run this and get the ID number:
2) Using ID number from previous query, run this:
Edit: at long last, the raw GQL:
(Easiest way: Use the implicit backreference property name; in the form “modelname_set”.)
or
I prefer this way:
The more involved way may sometimes be necessary: