Unverified Commit 72534607 authored by Serge S. Koval's avatar Serge S. Koval Committed by GitHub

Merge pull request #1947 from LvanWissen/associationproxy

Fix for loading association proxy results
parents 69a69847 ff8ebd2c
...@@ -69,7 +69,9 @@ class QueryAjaxModelLoader(AjaxModelLoader): ...@@ -69,7 +69,9 @@ class QueryAjaxModelLoader(AjaxModelLoader):
def get_list(self, term, offset=0, limit=DEFAULT_PAGE_SIZE): def get_list(self, term, offset=0, limit=DEFAULT_PAGE_SIZE):
query = self.get_query() query = self.get_query()
filters = (cast(field, String).ilike(u'%%%s%%' % term) for field in self._cached_fields) # no type casting to string if a ColumnAssociationProxyInstance is given
filters = (field.ilike(u'%%%s%%' % term) if is_association_proxy(field)
else cast(field, String).ilike(u'%%%s%%' % term) for field in self._cached_fields)
query = query.filter(or_(*filters)) query = query.filter(or_(*filters))
if self.filters: if self.filters:
......
...@@ -216,4 +216,6 @@ def is_relationship(attr): ...@@ -216,4 +216,6 @@ def is_relationship(attr):
def is_association_proxy(attr): def is_association_proxy(attr):
if hasattr(attr, 'parent'):
attr = attr.parent
return hasattr(attr, 'extension_type') and attr.extension_type == ASSOCIATION_PROXY return hasattr(attr, 'extension_type') and attr.extension_type == ASSOCIATION_PROXY
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