Fix SQLAlchemy ambiguous FK error between SpecVersion and ProcessingJob
Add explicit foreign_keys argument to both sides of the bidirectional relationship to resolve the multiple FK paths (SpecVersion.processing_job_id and ProcessingJob.spec_version_id). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
2c6f3d0686
commit
4833fa127d
1 changed files with 8 additions and 2 deletions
|
|
@ -250,7 +250,10 @@ 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")
|
||||
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"),
|
||||
|
|
@ -279,4 +282,7 @@ 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")
|
||||
spec_version: Mapped[Optional["SpecVersion"]] = relationship(
|
||||
"SpecVersion", back_populates="processing_job",
|
||||
foreign_keys="[ProcessingJob.spec_version_id]",
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue