diff options
author | Mitch Garnaat <mitch@cloudright.com> | 2010-08-20 16:16:10 -0400 |
---|---|---|
committer | Mitch Garnaat <mitch@cloudright.com> | 2010-08-20 16:16:10 -0400 |
commit | 145df1d1802d0ac490eede525c77dcf3c54b6d9d (patch) | |
tree | 35296f22f652a58efd2d964df945027592588ca2 | |
parent | 892cf061e5d8ec9c1beea05159fd3272788d5cdc (diff) | |
parent | 9731c220f2611db6aec645a0e322b0317663a1f2 (diff) | |
download | boto-145df1d1802d0ac490eede525c77dcf3c54b6d9d.tar.gz |
Merge branch 'master' of github.com:boto/boto
-rw-r--r-- | boto/sdb/db/manager/sdbmanager.py | 8 | ||||
-rw-r--r-- | boto/sdb/db/query.py | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/boto/sdb/db/manager/sdbmanager.py b/boto/sdb/db/manager/sdbmanager.py index 371c14aa..7221dfe2 100644 --- a/boto/sdb/db/manager/sdbmanager.py +++ b/boto/sdb/db/manager/sdbmanager.py @@ -445,13 +445,17 @@ class SDBManager(object): query.rs = rs return self._object_lister(query.model_class, rs) - def count(self, cls, filters): + def count(self, cls, filters, quick=True): """ Get the number of results that would be returned in this query """ query = "select count(*) from `%s` %s" % (self.domain.name, self._build_filter_part(cls, filters)) - count = int(self.domain.select(query).next()["Count"]) + count = 0 + for row in self.domain.select(query): + count += int(row['Count']) + if quick: + return count return count diff --git a/boto/sdb/db/query.py b/boto/sdb/db/query.py index 2660a42d..dfbe593d 100644 --- a/boto/sdb/db/query.py +++ b/boto/sdb/db/query.py @@ -53,8 +53,8 @@ class Query(object): self.offset = offset return self - def count(self): - return self.manager.count(self.model_class, self.filters) + def count(self, quick=True): + return self.manager.count(self.model_class, self.filters, quick) def get_query(self): return self.manager._build_filter_part(self.model_class, self.filters, self.sort_by) |