- changed status to resolved
abstractconcretebase polish
Issue #2950
resolved
seems to not be putting the class name into declarative registry:
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base, AbstractConcreteBase
Base = declarative_base()
class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
class BC(AbstractConcreteBase, Base):
pass
class B(BC):
__tablename__ = 'b'
id = Column(Integer, primary_key=True)
a_id = Column(Integer, ForeignKey('a.id'))
__mapper_args__ = {
"polymorphic_identity": "b",
"concrete": True
}
class C(BC):
__tablename__ = 'c'
id = Column(Integer, primary_key=True)
a_id = Column(Integer, ForeignKey('a.id'))
__mapper_args__ = {
"polymorphic_identity": "c",
"concrete": True
}
# fails
#A.collection = relationship("BC", primaryjoin="BC.a_id == A.id")
# workaround
configure_mappers()
A.collection = relationship(BC, primaryjoin=BC.a_id == A.id)
check if there's a dupe for this also
Comments (1)
-
reporter - Log in to comment
4a79bc578c67297c707a00d8faf