From a0d7ba2ab5cf10775cc1c767e0795e1dd6edba11 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 7 Jan 2016 09:38:00 +0530 Subject: [PATCH] use subquery for not in list --- oml/queryparser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/oml/queryparser.py b/oml/queryparser.py index a7dbfbe..e4c4196 100644 --- a/oml/queryparser.py +++ b/oml/queryparser.py @@ -4,6 +4,7 @@ from datetime import datetime import unicodedata from sqlalchemy.sql import operators +from sqlalchemy.orm import load_only import utils import settings @@ -121,7 +122,7 @@ class Parser(object): u = self._user.query.filter_by(id=settings.USER_ID).one() l = self._list.query.filter_by(user_id=u.id, name=name).one() 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) else: if l.type == 'smart':