I have a SQL Alchemy mapping:
class Employee(Base):
__tablename__ = 'employee'
id = Column(Integer, primary_key=True)
first_name = Column(String)
last_name = Column(String)
@hybrid_property
def me(self):
return 'Yes!' if self.first_name == 'ritratt' else 'Nope...'
Now I simply want to do a query like so:
session.query(Employee.me).all()
But it does not work because SQL Alchemy expects a column or expression instead of a str. The solution is to use hybrid_expression but I do not want to use expressions. I want my mapping to only use hybrid property.
How can I write a mapping with a hybrid_property that returns a str and work with query()?