Folks I have this toy example I've sanitized.
class TableBase(AbstractConcreteBase, Base):
pass
class TableA(TableBase):
__tablename__ = "table_a"
__mapper_args__ = {
"polymorphic_identity": "A",
"concrete": True,
}
v0 = Column(Integer)
@hybrid_property
def magic(self):
return self.v0 * 100
@magic.expression
def magic(cls):
return cls.v0 * 100
class TableB(TableBase):
__tablename__ = "table_b"
__mapper_args__ = {
"polymorphic_identity": "B",
"concrete": True,
}
v0 = Column(Integer)
@hybrid_property
def magic(self):
return self.v0 * 10
@magic.expression
def magic(cls):
return cls.v0 * 10
When I query at the top level:
print(Query([TableBase.magic]).limit(1).statement)
I get
AttributeError: type object 'TableBase' has no attribute 'magic'
I've tried a bunch of things, most of them point to the fact that the
hybrid_property is not being rendered in the subquery.
I did solve it by moving the hybrid_property into the abstract class,
though I want the particularities of a table to stay with the table
definition and not at the union level.
Thoughts? Ideas?
Thanks!!!
--Damian
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sqlalchemy/fee90588-8431-4e51-9f3a-39af6544bde1%40googlegroups.com.