I am trying to use a SQLAlchemy hybrid property like this
class Metric(Base):
__tablename__ = \'metric\'
id = Column(Integer, primary_key=True)
v
You need to create expression
from sqlalchemy import func
class Metric(Base):
__tablename__ = 'metric'
id = Column(Integer, primary_key=True)
value = Column(Float, nullable=False)
@hybrid_property
def dominance(self):
return 1 - abs(0.5 - self.value)
@dominance.expression
def dominance(cls):
return 1 - func.abs(0.5 - cls.value)