On Mar 19, 2012, at 8:29 AM, sandro dentella wrote: > Hi, > > if you have a std: > > class Director(Base): > name = ... > movies = relationship(Movie...) > > you can do something as:: > > session.query(Director).filter_by(movies=None) > > that is nicely translated into:: > > SELECT director.id AS director_id, director.last_name AS > director_last_name, director.first_name AS director_first_name, > director.nation AS director_nation > FROM director > WHERE NOT (EXISTS (SELECT 1 > FROM movie > WHERE director.id = movie.director_id)) > > > How can I nagate it, i.e. If I want all records that *do* have movies?
you'd get that using filter(Director.movies.any()). -- 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.
