X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fdjango-ldapdb.git;a=blobdiff_plain;f=ldapdb%2Fbackends%2Fldap%2Fcompiler.py;h=972606ff4589147a60ec52aa36b26038e047dbe5;hp=0b6eb7f5336e2b581e9e9097b7b3db38628991e1;hb=9d47feca75ea3778021284608f2fd050ec7b1563;hpb=128dc2edeee9d41b7288f0ef3e3e6183aec70a69 diff --git a/ldapdb/backends/ldap/compiler.py b/ldapdb/backends/ldap/compiler.py index 0b6eb7f..972606f 100644 --- a/ldapdb/backends/ldap/compiler.py +++ b/ldapdb/backends/ldap/compiler.py @@ -96,6 +96,10 @@ class SQLCompiler(object): if result_type !=compiler.SINGLE: raise Exception("LDAP does not support MULTI queries") + for key, aggregate in self.query.aggregate_select.items(): + if not isinstance(aggregate, aggregates.Count): + raise Exception("Unsupported aggregate %s" % aggregate) + try: vals = self.connection.search_s( self.query.model.base_dn, @@ -106,11 +110,17 @@ class SQLCompiler(object): except ldap.NO_SUCH_OBJECT: vals = [] + if not vals: + return None + output = [] + for alias, col in self.query.extra_select.iteritems(): + output.append(col[0]) for key, aggregate in self.query.aggregate_select.items(): - if not isinstance(aggregate, aggregates.Count): - raise Exception("Unsupported aggregate %s" % aggregate) - output.append(len(vals)) + if isinstance(aggregate, aggregates.Count): + output.append(len(vals)) + else: + output.append(None) return output def results_iter(self): @@ -190,7 +200,7 @@ class SQLDeleteCompiler(compiler.SQLDeleteCompiler, SQLCompiler): self.query.model.base_dn, self.query.model.search_scope, filterstr=query_as_ldap(self.query), - attrlist=[], + attrlist=['dn'], ) except ldap.NO_SUCH_OBJECT: return