Holy moley is it hard to do MUCK stuff relationally.
This commit is contained in:
parent
c72417e5e4
commit
d9ed6d5cd7
8 changed files with 89 additions and 24 deletions
|
|
@ -1,5 +1,5 @@
|
|||
from sqlalchemy import Column, Integer, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.orm import relationship, foreign, remote
|
||||
|
||||
from crudkit.core.base import CRUDMixin
|
||||
|
||||
|
|
@ -11,8 +11,11 @@ class Exit(Dbref):
|
|||
id = Column(Integer, ForeignKey("dbref.id"), primary_key=True)
|
||||
|
||||
destination_id = Column(Integer, ForeignKey("dbref.id"), nullable=True)
|
||||
destination = relationship("Dbref", remote_side=[CRUDMixin.id], foreign_keys=[destination_id])
|
||||
destination = relationship("Dbref", remote_side=[CRUDMixin.id], foreign_keys=[destination_id], primaryjoin=lambda: foreign(Exit.destination_id) == remote(Dbref.id))
|
||||
|
||||
source = relationship("Dbref", back_populates="exits", foreign_keys=[Dbref.location_id], remote_side=[Dbref.id])
|
||||
|
||||
__mapper_args__ = {
|
||||
"polymorphic_identity": ObjectType.EXIT
|
||||
"polymorphic_identity": ObjectType.EXIT,
|
||||
"inherit_condition": id == Dbref.id
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue