Aggregates of allow_none=False columns break for empty result sets
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Storm |
Fix Released
|
Medium
|
James Henstridge |
Bug Description
Aggregates return NULL if they are applied to an empty result set.
The ResultSet aggregate code tries to convert the return value to the same variable type as used by the column being aggregated. If that column uses allow_none=False and the result set in question is empty then this conversion results in a NoneError.
Test code:
from storm.locals import *
class Foo(object):
id = Int(primary=True)
number = Int(allow_
store = Store(create_
store.execute(
"CREATE TABLE foo (id INTEGER PRIMARY KEY, number INTEGER NOT NULL)")
result = store.find(Foo)
print result.
Failure:
Traceback (most recent call last):
File "breakme.py", line 13, in <module>
print result.
File "storm/store.py", line 1220, in max
return self._aggregate
File "storm/store.py", line 1210, in _aggregate
File "storm/
File "storm/
File "storm/
raise NoneError("None isn't acceptable as a value for %s" % name)
storm.
Related branches
- Jamu Kakar (community): Approve
- John O'Brien (community): Approve
-
Diff: 67 lines2 files modifiedstorm/store.py (+1/-1)
tests/store/base.py (+30/-0)
Changed in storm: | |
milestone: | none → 0.16 |
assignee: | nobody → James Henstridge (jamesh) |
status: | New → In Progress |
importance: | Undecided → Medium |
Changed in storm: | |
status: | Fix Committed → Fix Released |
Fix merged to trunk in r336.