Hi list,

In my use case I have

groups that can include other groups (many to many)
groups can also include users (many to many)

users can 'have feelings' to other users (many to many)

What I want to achieve is :

for a given group, recursively find its sub users
for each of those users, I need the list of the users they ('like' | 'love' 
| 'hate' ... filter on this criteria)

we discussed the recursive point here : 
http://www.mail-archive.com/sqlalchemy@googlegroups.com/msg24742.html

so I manage to have a query that when executed returns a list of all sub 
users (of class User)
searched group is the starting point (Group object)
content_q = searched_group.get_all_users()

of course, I can iterate on the result of this query, and then create a 
dict of list (or whatever)
            all_users = set(content_q.all())
            result = {}
            for user in all_users:
                result['user.id']=[]
                    for other in user.my_feelings(feeling='love'):
                        result['user.id'].append((other.id, other.name))



Still as all those tables join, I have a feeling this could be accomplished 
in a single query
maybe not ?

thanks for any idea

NiL

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/3TrJBLp82toJ.
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