title: flask SQLAlchemy hybrid_property Boolean value of this clause is not defined
body: <p>I'm using Python 3.6.5, Flask 1.0.2, SQLAlchemy 1.0.5 and I want to define an attribute as a maximum between other two, based on <a href="https://github.com/flask-admin/flask-admin/blob/master/examples/sqla-hybrid_property/app.py" rel="nofollow noreferrer">flask-admin hybrid property example</a>:</p>
  
  <pre><code>from flask import Flask
  from flask_sqlalchemy import SQLAlchemy
  from sqlalchemy.ext.hybrid import hybrid_property
  
  import flask_admin as admin
  from flask_admin.contrib import sqla
  
  from sqlalchemy.sql.expression import func
  
  # Create application
  app = Flask(__name__)
  
  # Create dummy secrey key so we can use sessions
  app.config['SECRET_KEY'] = '123456790'
  
  # Create in-memory database
  app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///sample_db_2.sqlite'
  app.config['SQLALCHEMY_ECHO'] = True
  db = SQLAlchemy(app)
  
  
  # Flask views
  @app.route('/')
  def index():
      return '&lt;a href="/admin/"&gt;Click me to get to Admin!&lt;/a&gt;'
  
  
  class Screen(db.Model):
      __tablename__ = 'screen'
      id = db.Column(db.Integer, primary_key=True)
      width = db.Column(db.Integer, nullable=False)
      height = db.Column(db.Integer, nullable=False)
  
      @hybrid_property
      def max(self):
          return max(self.height, self.width)
  
  class ScreenAdmin(sqla.ModelView):
      """ Flask-admin can not automatically find a hybrid_property yet. You will
          need to manually define the column in list_view/filters/sorting/etc."""
      column_list = ['id', 'width', 'height', 'max']
      column_sortable_list = ['id', 'width', 'height', 'max']
  
      # Flask-admin can automatically detect the relevant filters for hybrid properties.
      column_filters = ('max', )
  
  
  # Create admin
  admin = admin.Admin(app, name='Example: SQLAlchemy2', template_mode='bootstrap3')
  admin.add_view(ScreenAdmin(Screen, db.session))
  
  if __name__ == '__main__':
  
      # Create DB
      db.create_all()
  
      # Start app
      app.run(debug=True)
  </code></pre>
  
  <p>But it fails, raising this error:</p>
  
  <pre><code>    raise TypeError("Boolean value of this clause is not defined")
  </code></pre>
  
  <p>Traceback:</p>
  
  <pre><code>/home/bibo/usr/miniconda/envs/otroflask/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py:794: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True or False to suppress this warning.
    'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
  Traceback (most recent call last):
    File "app.py", line 49, in &lt;module&gt;
      admin.add_view(ScreenAdmin(Screen, db.session))
    File "/home/bibo/usr/miniconda/envs/otroflask/lib/python3.6/site-packages/flask_admin/contrib/sqla/view.py", line 329, in __init__
      menu_icon_value=menu_icon_value)
    File "/home/bibo/usr/miniconda/envs/otroflask/lib/python3.6/site-packages/flask_admin/model/base.py", line 804, in __init__
      self._refresh_cache()
    File "/home/bibo/usr/miniconda/envs/otroflask/lib/python3.6/site-packages/flask_admin/model/base.py", line 881, in _refresh_cache
      self._list_columns = self.get_list_columns()
    File "/home/bibo/usr/miniconda/envs/otroflask/lib/python3.6/site-packages/flask_admin/model/base.py", line 1022, in get_list_columns
      excluded_columns=self.column_exclude_list,
    File "/home/bibo/usr/miniconda/envs/otroflask/lib/python3.6/site-packages/flask_admin/contrib/sqla/view.py", line 531, in get_column_names
      column, path = tools.get_field_with_path(self.model, c)
    File "/home/bibo/usr/miniconda/envs/otroflask/lib/python3.6/site-packages/flask_admin/contrib/sqla/tools.py", line 150, in get_field_with_path
      value = getattr(current_model, attribute)
    File "/home/bibo/usr/miniconda/envs/otroflask/lib/python3.6/site-packages/sqlalchemy/ext/hybrid.py", line 867, in __get__
      return self._expr_comparator(owner)
    File "/home/bibo/usr/miniconda/envs/otroflask/lib/python3.6/site-packages/sqlalchemy/ext/hybrid.py", line 1066, in expr_comparator
      owner, self.__name__, self, comparator(owner),
    File "/home/bibo/usr/miniconda/envs/otroflask/lib/python3.6/site-packages/sqlalchemy/ext/hybrid.py", line 1055, in _expr
      return ExprComparator(cls, expr(cls), self)
    File "app.py", line 34, in number_of_pixels
      return max(self.width,self.height)
    File "/home/bibo/usr/miniconda/envs/otroflask/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 2975, in __bool__
      raise TypeError("Boolean value of this clause is not defined")
  </code></pre>
  
  <p>I've tried with the max sqlalchemy function:</p>
  
  <pre><code>return func.max(self.height, self.width)
  </code></pre>
  
  <p>But it returns literally a function not a value.</p>
  
  <p>I also tried to use concept of <a href="https://stackoverflow.com/questions/42681231/sqlalchemy-boolean-value-of-this-clause-is-not-defined#42695255">this answer</a>, without success.</p>