don't forget to use offset/limit in get_count()
authorjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Tue, 1 Jun 2010 16:28:48 +0000 (16:28 +0000)
committerjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Tue, 1 Jun 2010 16:28:48 +0000 (16:28 +0000)
git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@920 e071eeec-0327-468d-9b6a-08194a12b294

ldapdb/models/query.py

index 07a6312bc182f2e6d3cb240f8198b204758df9e8..3076e3f3364905bf2a272be6ad31934641cde093 100644 (file)
@@ -211,7 +211,15 @@ class Query(BaseQuery):
             )
         except ldap.NO_SUCH_OBJECT:
             return 0
-        return len(vals)
+
+        number = len(vals)
+
+        # apply limit and offset
+        number = max(0, number - self.low_mark)
+        if self.high_mark is not None:
+            number = min(number, self.high_mark - self.low_mark)
+
+        return number
 
     def get_compiler(self, using=None, connection=None):
         return Compiler(self, ldapdb.connection, using)