Fixed sum and average mapreduce function for issue #375

This commit is contained in:
kelvinhammond 2013-06-19 10:34:33 -04:00
parent 44a2a164c0
commit c31d6a6898
2 changed files with 4 additions and 3 deletions

View File

@ -16,6 +16,7 @@ Dervived from the git logs, inevitably incomplete but all of whom and others
have submitted patches, reported bugs and generally helped make MongoEngine
that much better:
* Kelvin Hammond (https://github.com/kelvinhammond)
* Harry Marr
* Ross Lawley
* blackbrrr

View File

@ -1062,7 +1062,7 @@ class QuerySet(object):
"""
map_func = Code("""
function() {
emit(1, this[field] || 0);
emit(1, eval("this." + field) || 0);
}
""", scope={'field': field})
@ -1093,7 +1093,7 @@ class QuerySet(object):
map_func = Code("""
function() {
if (this.hasOwnProperty(field))
emit(1, {t: this[field] || 0, c: 1});
emit(1, {t: eval("this." + field) || 0, c: 1});
}
""", scope={'field': field})