restrict selected fields
authorjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Tue, 1 Jun 2010 12:59:46 +0000 (12:59 +0000)
committerjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Tue, 1 Jun 2010 12:59:46 +0000 (12:59 +0000)
git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@916 e071eeec-0327-468d-9b6a-08194a12b294

ldapdb/models/query.py

index e4226309af8cdbdf6728cef96803f9b17679e29e..e55c1610a2f2f46043d63f34ea74f505d90627f9 100644 (file)
@@ -71,7 +71,12 @@ class Compiler(object):
 
     def results_iter(self):
         query = self.query
-        attrlist = [ x.db_column for x in query.model._meta.local_fields if x.db_column ]
+        if self.query.select_fields:
+            fields = self.query.select_fields
+        else:
+            fields = self.query.model._meta.fields
+
+        attrlist = [ x.db_column for x in fields if x.db_column ]
 
         try:
             vals = self.connection.search_s(
@@ -123,7 +128,7 @@ class Compiler(object):
                 pos += 1
                 continue
             row = []
-            for field in iter(query.model._meta.fields):
+            for field in iter(fields):
                 if field.attname == 'dn':
                     row.append(dn)
                 elif hasattr(field, 'from_ldap'):