I have a declarative class structure that looks like this:
class BaseClass(Base):
Column A
Column B
class Mixin(object):
Column C
class ItemA(BaseClass):
Column D
class ItemB(Mixin, BaseClass):
pass
class ItemC(Mixin, BaseClass):
Column E
Is there a way I can use with_polymorphic such that I can do a query based on Column C across all of the Items, without having to explicitly know what Items I have? Something like essentially
mixin_poly = with_polymorphic(base = BaseClass, classes = MixinClass.__subclasses__())
Lets assume that at import time all of the derivatives of MixinClass would have been imported before the with_polymorphic is declared.
Edit Note that I've left out the boilerplate for joined-table inheritance, but assume it's properly set up such that doing
poly_base = with_polymorphic(base = BaseClass, classes = '*')
session.query(poly_base).filter(BaseClass.a == value, ...)
performs as expected for querying columns from BaseClass. The point is to be able to query common columns in the subclasses that inherit the Mixin class in the same manner.