From 6ee56eaf3b6df1deb055443f85aecb0437cf8f29 Mon Sep 17 00:00:00 2001 From: jlaine Date: Mon, 7 Sep 2009 08:49:42 +0000 Subject: [PATCH] support multiple values in WHERE clause git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@648 e071eeec-0327-468d-9b6a-08194a12b294 --- ldapdb/models/query.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ldapdb/models/query.py b/ldapdb/models/query.py index 902d237..0aba5be 100644 --- a/ldapdb/models/query.py +++ b/ldapdb/models/query.py @@ -18,8 +18,6 @@ # along with this program. If not, see . # -# -*- coding: utf-8 -*- - from copy import deepcopy import ldap @@ -43,10 +41,15 @@ class WhereNode(BaseWhereNode): else: # django 1.0 table, column, type, x, y, values = item + equal_bits = [ "(%s=%s)" % (column, value) for value in values ] + if len(equal_bits) > 1: + clause = '(|%s)' % ''.join(equal_bits) + else: + clause = equal_bits[0] if self.negated: - bits.append('(!(%s=%s))' % (column,values[0])) + bits.append('(!%s)' % clause) else: - bits.append('(%s=%s)' % (column,values[0])) + bits.append(clause) if len(bits) == 1: return bits[0] elif self.connector == AND: -- 2.30.2