Commit dc29c583 authored by Sergey Markelov's avatar Sergey Markelov

*) Don't apply filter if the term is empty

   see https://github.com/mrjoes/flask-admin/pull/535
parent 1ca37549
......@@ -50,6 +50,7 @@ class QueryAjaxModelLoader(AjaxModelLoader):
def get_list(self, term, offset=0, limit=DEFAULT_PAGE_SIZE):
query = self.model.objects
if len(term) > 0:
criteria = None
for field in self._cached_fields:
......
......@@ -52,6 +52,7 @@ class QueryAjaxModelLoader(AjaxModelLoader):
def get_list(self, term, offset=0, limit=DEFAULT_PAGE_SIZE):
query = self.model.select()
if len(term) > 0:
stmt = None
for field in self._cached_fields:
q = field ** (u'%%%s%%' % term)
......
......@@ -58,6 +58,7 @@ class QueryAjaxModelLoader(AjaxModelLoader):
def get_list(self, term, offset=0, limit=DEFAULT_PAGE_SIZE):
query = self.session.query(self.model)
if len(term) > 0:
filters = (field.like(u'%%%s%%' % term) for field in self._cached_fields)
query = query.filter(or_(*filters))
......
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