Commit 1eb5c806 authored by Tom Kedem's avatar Tom Kedem

fixed hybrid property detection and made it robust.

parent bd1a80b8
......@@ -2,6 +2,7 @@ from sqlalchemy import tuple_, or_, and_
from sqlalchemy.sql.operators import eq
from sqlalchemy.exc import DBAPIError
from sqlalchemy.orm.attributes import InstrumentedAttribute
from sqlalchemy_utils import get_hybrid_properties
from flask_admin._compat import filter_list, string_types
from flask_admin.tools import iterencode, iterdecode, escape
......@@ -170,3 +171,7 @@ def get_field_with_path(model, name):
path.append(column.table)
return attr, path
def is_hybrid_property(model, attr_name):
return attr_name in get_hybrid_properties(model)
......@@ -2,7 +2,6 @@ import logging
import warnings
import inspect
from sqlalchemy.ext.hybrid import HYBRID_PROPERTY
from sqlalchemy.orm.attributes import InstrumentedAttribute
from sqlalchemy.orm import joinedload, aliased
from sqlalchemy.sql.expression import desc
......@@ -604,7 +603,7 @@ class ModelView(BaseModelView):
return filters
else:
is_hybrid_property = hasattr(attr, 'descriptor') and attr.descriptor.extension_type == HYBRID_PROPERTY
is_hybrid_property = tools.is_hybrid_property(self.model, name)
if is_hybrid_property:
column = attr
else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment