8 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: Adding additional co...
FromSent OnAttachments
Toshio Kuratomi23 Jul 2008 16:58 
Kipb23 Jul 2008 20:01 
Toshio Kuratomi24 Jul 2008 01:42 
Toshio Kuratomi24 Jul 2008 17:35 
Kipb24 Jul 2008 20:35 
Toshio Kuratomi24 Jul 2008 23:26 
Bobby Impollonia25 Jul 2008 05:55 
Bobby Impollonia25 Jul 2008 10:12 
Subject:[sqlalchemy] Re: Adding additional conditions to an outer join
From:Kipb (kipb@gmail.com)
Date:07/24/2008 08:35:05 PM
List:com.googlegroups.sqlalchemy

On Jul 24, 8:36 pm, Toshio Kuratomi <a.ba@gmail.com> wrote:

If I understand your code, it doesn't give the expected output, at least with sqlalchemy-0.4.6.

I'm using 0.4.4 but not sure it matters, see below.

The way I'm reading your script, the first half implements what you're writing here and the second half ...

User(toshio,Toshio Kuratomi) UserGroup(pending) grpname= UserGroup User(admin,Admin User) ManagerGroup(pending) grpname= ManagerGroup ... So the first way doesn't show the "public" user who has no groups.  

Correct, it is only showing the 'pending' ones. Remove that line stmt = stmt.where(PersonRoles.role_status=='pending') and you get all of them, as you asked:

User(toshio,Toshio Kuratomi) UserGroup(pending) grpname= UserGroup User(public,Public Man) User(admin,Admin User) UserGroup(approved);ManagerGroup(pending) grpname= UserGroup

but I can't figure out how to limit the results to a specific group or null so that I get this:

User(toshio,Toshio Kuratomi) UserGroup(pending) pending User(public,Public Man)  None User(admin,Admin User) UserGroup(approved) approved

You're right about the bugs, but your original problem appears to be solved. You can limit to a specific group or add any other condition to the outer join.

If you want the users NOT in a group then use stmt = stmt.where(PersonRoles.role_status==None)