Skip to content

Commit

Permalink
raise NotSupportedError when len or bool is used on sqlite result (Bu…
Browse files Browse the repository at this point in the history
…g#179644)
  • Loading branch information
anandology committed Oct 23, 2009
1 parent a18473a commit 3cdaa14
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion web/db.py
Expand Up @@ -948,7 +948,9 @@ def query(self, *a, **kw):
out = DB.query(self, *a, **kw)
if isinstance(out, iterbetter):
# rowcount is not provided by sqlite
del out.__len__
def _len():
raise self.db_module.NotSupportedError("rowcount is not supported by sqlite")
out.__len__ = _len
return out

class FirebirdDB(DB):
Expand Down
4 changes: 4 additions & 0 deletions web/utils.py
Expand Up @@ -541,6 +541,10 @@ def __getitem__(self, i):
return self.i.next()
except StopIteration:
raise IndexError, str(i)

def __nonzero__(self):
return len(self) != 0

iterbetter = IterBetter

def dictreverse(mapping):
Expand Down

0 comments on commit 3cdaa14

Please sign in to comment.