Thanks for the response, works nice, however coming from PHP/MySQL
this seems strange to me.

We have two 'tables' and are trying to perform a query to link them,
however this solution causes two queries on the 'database' to be
performed, which are logged against you for your quotas.

I'm used to joins:
http://dev.mysql.com/doc/refman/5.0/en/join.html

One query linking two or more tables for the data you need.

Is Google App Engine's 'query' function not able to do anything like
this? Is GQL better than GAE's 'Query'?

On Sep 15, 12:41 pm, Arun Shanker Prasad <arunshankerpra...@gmail.com>
wrote:
> Hi,
>
> I am sorry I replied to the thread when I was not at my dev machine,
> did not test the code. I am not sure if putting the query inside the
> query.filter() will break it.
>
> owner = PetOwner.all().filter('name =', 'johndoe'),get()
> query.filter('owner = ', owner)
>
> This should work.
>
> Thanks,
> Arun Shanker Prasad.
>
> On Sep 16, 12:20 am, PatHaugen <pathau...@gmail.com> wrote:
>
> > I tested the filter you provided:
> > query.filter('owner = ', PetOwner.all().filter('name =', 'johndoe'))
>
> > However it didn't work.
>
> > I visited the doc you referenced, but the page does not mention
> > anything about the style of query filters or any information on
> > construction of queries with ReferenceProperty that I could find.
>
> > Does the query filter you wrote work on your side?
>
> > I broke our your query:
> > PetOwner.all().filter('name =', 'johndoe')
>
> > Which worked fine, however it was in placing it inside the
> > query.filter that I get an error.
>
> > Do you not get an error structured like this?
>
> > On Sep 15, 4:36 am, Arun Shanker Prasad <arunshankerpra...@gmail.com>
> > wrote:
>
> > > Hi,
>
> > > I think you are trying to filter the ReferenceProperty as a string,
> > > this won't work. You need to;
>
> > > query.filter('owner = ', PetOwner.all().filter('name =', 'johndoe'))
>
> > > Doc on the Datastore ReferenceProperty;
>
> > >http://code.google.com/appengine/docs/python/datastore/entitiesandmod...
>
> > > Thanks,
> > > Arun Shanker Prasad.
>
> > > On Sep 15, 8:54 am, PatHaugen <pathau...@gmail.com> wrote:
>
> > > > Jumping into GAE, I found the ReferenceProperty interesting but still
> > > > don't fully understand it.
>
> > > > My question can expand on the example 
> > > > from:http://code.google.com/appengine/docs/python/datastore/creatinggettin...
>
> > > > class PetOwner(db.Model):
> > > >   name = db.StringProperty()
> > > > class Pet(db.Model):
> > > >   name = db.StringProperty()
> > > >   type = db.StringProperty() # cat, dog, etc.
> > > >   owner = db.ReferenceProperty(PetOwner)
>
> > > > Let's do a query to select all cats with a specific owner.
>
> > > > query = db.Query(Pet)
> > > > query = Pet.all()
> > > > query.filter('type = ', 'Cat')
> > > > results = query.fetch(limit=10)
> > > > for result in results:
> > > >   output = result.name
> > > > return output
>
> > > > What can I add to this to filter only those where 'owner' is
> > > > 'johndoe'?
>
> > > > I tried:
> > > > query.filter('owner = ', 'johndoe')
>
> > > > However it fails to return me a result, and I know you can pull the
> > > > owner name via 'pet.owner.name' however trying:
> > > > query.filter('owner.name = ', 'johndoe')
>
> > > > Also fails, though it made sense for what should work. Does anyone
> > > > know the proper method?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to