I have a question about the Association Pattern
     
http://docs.sqlalchemy.org/en/latest/orm/relationships.html#association-object

I have a structure as such:
    useraccount
    group
    useraccount_2_group ( useraccount_id , group_id , metadata like
relation type / date / etc )

Is it possible to query the Groups based on the association ?

For example, in a webapp I have the useraccount_id from the session.
I don't want to load the useraccount object  , i might just want the
groups...

        """SELECT
                        g.*
                FROM
                        useraccount_2_group u2g
                        LEFT JOIN group g ON ( u2g.group_id = group.id )
                WHERE
                        u2g.useraccount_id = :useraccount_id"""

I guess I'm wondering if its possible to do:
    dbSession.query( Group ).filter_or_join_or_whatever()

Similarly, I might want to access the 'relationship' as well.  From
the docs, I don't understand if it would make more sense to load the
Relationship and then eagerly pull in the Group -- or to use a join
and grab a tuple [ 
http://docs.sqlalchemy.org/en/latest/orm/tutorial.html#selecting-entities-from-subqueries
].  Does anyone have a preference for a reason ?

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

Reply via email to