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')