handle searching on hybrid property

parent e91fa3eb
......@@ -572,14 +572,20 @@ class ModelView(BaseModelView):
if self.column_searchable_list:
self._search_fields = []
for p in self.column_searchable_list:
attr, joins = tools.get_field_with_path(self.model, p)
for name in self.column_searchable_list:
attr, joins = tools.get_field_with_path(self.model, name)
if not attr:
raise Exception('Failed to find field for search field: %s' % p)
raise Exception('Failed to find field for search field: %s' % name)
for column in tools.get_columns_for_field(attr):
if tools.is_hybrid_property(self.model, name):
column = attr
if isinstance(name, string_types):
column.key = name.split('.')[-1]
self._search_fields.append((column, joins))
else:
for column in tools.get_columns_for_field(attr):
self._search_fields.append((column, joins))
return bool(self.column_searchable_list)
......
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