Fix SpecVersion/ProcessingJob circular relationship direction error
Remove bidirectional back_populates between SpecVersion and ProcessingJob since both sides have FKs to each other (circular), causing SQLAlchemy to see both as MANYTOONE. ProcessingJob.spec_version is now a standalone relationship with explicit foreign_keys. SpecVersion no longer has a reverse relationship to ProcessingJob (not needed for any queries). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4833fa127d
commit
1601622e07
1 changed files with 2 additions and 6 deletions
|
|
@ -250,10 +250,6 @@ class SpecVersion(Base):
|
|||
|
||||
# Relationships
|
||||
knowledge_base: Mapped["KnowledgeBase"] = relationship("KnowledgeBase", back_populates="spec_versions")
|
||||
processing_job: Mapped[Optional["ProcessingJob"]] = relationship(
|
||||
"ProcessingJob", back_populates="spec_version",
|
||||
foreign_keys="[SpecVersion.processing_job_id]",
|
||||
)
|
||||
|
||||
__table_args__ = (
|
||||
UniqueConstraint("knowledge_base_id", "version_number", name="uq_kb_version_number"),
|
||||
|
|
@ -283,6 +279,6 @@ class ProcessingJob(Base):
|
|||
# Relationships
|
||||
knowledge_base: Mapped["KnowledgeBase"] = relationship("KnowledgeBase", back_populates="processing_jobs")
|
||||
spec_version: Mapped[Optional["SpecVersion"]] = relationship(
|
||||
"SpecVersion", back_populates="processing_job",
|
||||
foreign_keys="[ProcessingJob.spec_version_id]",
|
||||
"SpecVersion",
|
||||
foreign_keys=[spec_version_id],
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue