title: Filtering on SQLAlchemy @hybrid_property not working
body: <p>I have a SQLAlchemy Model as follows and am trying to filter on the isActive property.</p>
  <pre><code>query(PersonMedications).filter(PersonMedication.isActive==False).all()
  </code></pre>
  <hr />
  <pre><code>class PersonMedication(ModelAbstract):
  
      __tablename__ = &quot;personMedication&quot;
      id = db.Column(db.Integer, primary_key=True)
      startDate = db.Column(db.Date)
      endDate = db.Column(db.Date)
      isCanceled = db.Column(db.Boolean)
  
      @hybrid_property
      def isActive(self):
          if self.isCanceled == True:
              return False
          elif self.endDate and self.endDate &lt; datetime.date.today():
              return False
          elif self.startDate and self.startDate &lt;= datetime.date.today():
              return True
          else:
              return False
  </code></pre>
  <p>I am getting the following error:</p>
  <pre><code>TypeError: Boolean value of this clause is not defined
  </code></pre>
  <p>From looking at the SQLAlchemy docs it seems like my function should work.. What am I missing?</p>
  <p><a href="http://docs.sqlalchemy.org/en/rel_1_0/orm/extensions/hybrid.html" rel="nofollow noreferrer">http://docs.sqlalchemy.org/en/rel_1_0/orm/extensions/hybrid.html</a></p>
  <h1>UPDATES</h1>
  <p>Per @van's suggestions I figured out I need to use an expression function but cant seem to figure out the correct syntax for stringing together the logic.</p>
  <pre><code>@isActive.expression
  def isActive(cls):
      return not cls.isCanceled and cls.startDate &lt;= func.current_date()
     
  </code></pre>