this is a bit of a brain teaser because I don't know LINQ and we don't have an "all()" operator. Spent a few minutes trying to guess what the heck "all()" would query for; in SQL, it's very easy to check if a collection contains some elements with some kind of criteria...but "all", I thought, how can you ever know that there's not another row somewhere that isn't in the"all", which gave me the "duh" moment. for all() you need to check that there are "not any" of the *opposite* - e.g. no rows exist that don't match that criteria. We could add this operator really easily.
But for now query(Job).filter(Job.status == 'queued').filter(~Job.dependencies.any(Dependency.status != 'done')) On Apr 17, 2014, at 8:51 AM, Maik Riechert <maik.riech...@arcor.de> wrote: > Hi everyone, > > I am really lost on a query I try to formulate. In LINQ it would probably > like that (haven't done LINQ in quite some time): > > from j in Job > where j.status == 'queued' and j.dependencies.all(d => d.status == 'done') > select j > > So, Job.dependencies is a self-referential many-to-many association which > describes dependencies between processing jobs. And now I try to find those > queued jobs whose dependencies are finished. > > I'm brand new to sqlalchemy, I appreciate any help :) > > Thanks > Maik > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy+unsubscr...@googlegroups.com. > To post to this group, send email to sqlalchemy@googlegroups.com. > Visit this group at http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.