On Tue, Mar 3, 2009 at 16:09, grat <[email protected]> wrote:

> i have table:
>
> class Test1(Entity):
>    name=Field(String(20))
>    test2s=ManyToMany("test2")
>
> class Test2(Entity):
>    name=Field(String(20))
>    testin=ManyToMany("test1")
>
> -----------
> i now need get all rows from test1 why rows not in in relations with
> test2

It's easier if you add an inverse relationship.

t2 = Test2.get_by(id=1)     #
t1s = Test1.query.filter(~Test1.test2s.contains(t2))

note the ~ operator, which means “NOT”

See
http://www.sqlalchemy.org/docs/05/ormtutorial.html#using-exists
and below

-- 
Gaëtan de Menten
http://openhex.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" 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/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to