On Jan 30, 2009, at 1:39 PM, Hans Lellelid wrote:

>
> Hi,
>
> I did a quick search but couldn't find the "right" way to do this in
> SA.
>
> For the sake of example, I have a many-to-many relationshp between
> Book and Reader.  The 'books' property of reader is loaded using
> lazy='dynamic'.  And, finally, Book is mapped with single-table
> inheritance and has subclasses for various genres.  -- this is just an
> example :)
>
> This works:
> reader = session.query(Reader).first()
> mysterybooks = reader.books.filter
> (Book.genre==MysteryBook.DESCRIMINATOR_KEY)
>
> However, this doesn't feel like the *right* way.  I experimented with
> various forms of of_type() but didn't get it to work.  I'm sure I'm
> just not fully understanding how that is supposed to work.

of_type() is currently only implemented for a RelationProperty and  
takes effect for EXISTS subqueries generated by has()/any() and  
query.join().    So for the dynamic loader's list of books, what  
you're doing is the best option we have at the moment.   it seems like  
of_type() existing on Query as a generative method would be the way to  
go here...until someone says "query(A, B, C).of_type(A)".....

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to