On Mar 15, 2012, at 10:03 PM, Michael Bayer wrote:

>> And here is my best attempt at doing the same thing in sqlalchemy:
>> Job_A = aliased(Job)
>> DBSession.query(Job_A).join(DataContainer).filter(~ 
>> DataContainer.jobs.any(Job.id < Job_A.id)).all()
> 
> 
> any_query = exists().where(Job_A.container_id==DataContainer.id).\
>                                    where(Job_A.id<Job.id).\
>                                    correlate(Job.__table__).\
>                                    correlate(DataContainer.__table__)
> 
> where similarly, the need to say __table__ will also be fixed in 0.8, you'll 
> be able to say things like correlate(Job).

this works too, to get what you were trying to do in the original:

q = session.query(Job_A).join(DataContainer).\
                    filter(~DataContainer.jobs.any(Job_A.id<Job.container_id).
                                    correlate(Job.__table__))


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
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