avoid extra condition containing all items

This commit is contained in:
j 2016-02-26 18:06:45 +05:30
parent b9508b623a
commit 2345fc885d

View file

@ -52,10 +52,14 @@ def find(data):
g = state.cache.get(key) g = state.cache.get(key)
if g is None: if g is None:
state.cache.lock(key) state.cache.lock(key)
items = q['qs'].options(load_only('id')) if data.get('query', {}).get('conditions'):
items = q['qs'].options(load_only('id'))
else:
items = None
qs = models.Find.query.filter_by(key=q['group']) qs = models.Find.query.filter_by(key=q['group'])
if items.first(): if items is None or items.first():
qs = qs.filter(models.Find.item_id.in_(items)) if items is not None:
qs = qs.filter(models.Find.item_id.in_(items))
values = list(qs.values('value', 'findvalue', 'sortvalue')) values = list(qs.values('value', 'findvalue', 'sortvalue'))
for f in values: for f in values:
value = f[0] value = f[0]