Exemplo n.º 1
0
    def test_has_inherited_table_doesnt_consider_base(self):
        class A(Base):
            __tablename__ = "a"
            id = Column(Integer, primary_key=True)

        assert not has_inherited_table(A)

        class B(A):
            __tablename__ = "b"
            id = Column(Integer, ForeignKey("a.id"), primary_key=True)

        assert has_inherited_table(B)
Exemplo n.º 2
0
 def __mapper_args__(cls):
     if not has_inherited_table(cls):
         ret = {
             "polymorphic_identity": "default",
             "polymorphic_on": cls.type,
         }
     else:
         ret = {"polymorphic_identity": cls.__name__}
     return ret