>
>
>> query(Job).filter(Job.status ==
>> ‘queued’).filter(~Job.dependencies.any(Dependency.status != ‘done’))
>>
>>
One more thing. Dependency doesn't exist as a class. Job.dependencies is a
many-to-many association. That's why you probably have to use aliases to
refer to the status of the dependency Job. I just couldn't get it to work
though. The basic model:
# many-to-many association table
JobDependency = Table('job_dependency', Base.metadata,
Column('jobId', Integer, ForeignKey('job.id'), primary_key=True),
Column('dependsOnJobId', Integer, ForeignKey('job.id'),
primary_key=True)
)
class Job(Base):
__tablename__ = 'job'
id = Column(Integer, primary_key=True)
status = Column(String(20), default='queued', nullable=False)
dependencies = relationship(lambda: Job,
secondary=JobDependency,
primaryjoin=id==JobDependency.c.jobId,
secondaryjoin=id==JobDependency.c.dependsOnJobId,
backref='dependencyOf')
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.