support multiple values in WHERE clause
authorjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Mon, 7 Sep 2009 08:49:42 +0000 (08:49 +0000)
committerjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Mon, 7 Sep 2009 08:49:42 +0000 (08:49 +0000)
git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@648 e071eeec-0327-468d-9b6a-08194a12b294

ldapdb/models/query.py

index 902d23713566abaed295050faa9b8aa22ac238f2..0aba5be23280063259e8b236f48d5b2d1345f577 100644 (file)
@@ -18,8 +18,6 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-# -*- 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: