use subquery for not in list

This commit is contained in:
j 2016-01-07 09:38:00 +05:30
parent 9b76d89cfa
commit a0d7ba2ab5

View file

@ -4,6 +4,7 @@
from datetime import datetime from datetime import datetime
import unicodedata import unicodedata
from sqlalchemy.sql import operators from sqlalchemy.sql import operators
from sqlalchemy.orm import load_only
import utils import utils
import settings import settings
@ -121,7 +122,7 @@ class Parser(object):
u = self._user.query.filter_by(id=settings.USER_ID).one() u = self._user.query.filter_by(id=settings.USER_ID).one()
l = self._list.query.filter_by(user_id=u.id, name=name).one() l = self._list.query.filter_by(user_id=u.id, name=name).one()
if exclude: if exclude:
ids = [i.id for i in l.get_items()] ids = l.user.items.filter(self._list.id==l.id).options(load_only('id'))
q = operators.notin_op(self._model.id, ids) q = operators.notin_op(self._model.id, ids)
else: else:
if l.type == 'smart': if l.type == 'smart':