Fixed sum and average mapreduce function for issue #375
This commit is contained in:
		
							
								
								
									
										3
									
								
								AUTHORS
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								AUTHORS
									
									
									
									
									
								
							| @@ -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 | have submitted patches, reported bugs and generally helped make MongoEngine | ||||||
| that much better: | that much better: | ||||||
|  |  | ||||||
|  |  * Kelvin Hammond (https://github.com/kelvinhammond) | ||||||
|  * Harry Marr |  * Harry Marr | ||||||
|  * Ross Lawley |  * Ross Lawley | ||||||
|  * blackbrrr |  * blackbrrr | ||||||
| @@ -169,4 +170,4 @@ that much better: | |||||||
|  * Massimo Santini (https://github.com/mapio) |  * Massimo Santini (https://github.com/mapio) | ||||||
|  * Nigel McNie (https://github.com/nigelmcnie) |  * Nigel McNie (https://github.com/nigelmcnie) | ||||||
|  * ygbourhis (https://github.com/ygbourhis) |  * ygbourhis (https://github.com/ygbourhis) | ||||||
|  * Bob Dickinson (https://github.com/BobDickinson) |  * Bob Dickinson (https://github.com/BobDickinson) | ||||||
|   | |||||||
| @@ -1062,7 +1062,7 @@ class QuerySet(object): | |||||||
|         """ |         """ | ||||||
|         map_func = Code(""" |         map_func = Code(""" | ||||||
|             function() { |             function() { | ||||||
|                 emit(1, this[field] || 0); |                 emit(1, eval("this." + field) || 0); | ||||||
|             } |             } | ||||||
|         """, scope={'field': field}) |         """, scope={'field': field}) | ||||||
|  |  | ||||||
| @@ -1093,7 +1093,7 @@ class QuerySet(object): | |||||||
|         map_func = Code(""" |         map_func = Code(""" | ||||||
|             function() { |             function() { | ||||||
|                 if (this.hasOwnProperty(field)) |                 if (this.hasOwnProperty(field)) | ||||||
|                     emit(1, {t: this[field] || 0, c: 1}); |                     emit(1, {t: eval("this." + field) || 0, c: 1}); | ||||||
|             } |             } | ||||||
|         """, scope={'field': field}) |         """, scope={'field': field}) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user