{"issue":{"state":"closed","pull_request":{"diff_url":"https://github.com/hmarr/mongoengine/pull/346.diff","html_url":"https://github.com/hmarr/mongoengine/pull/346","patch_url":"https://github.com/hmarr/mongoengine/pull/346.patch"},"user":{"avatar_url":"https://secure.gravatar.com/avatar/dab3070687bb065a7d43df70c9651375?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"dab3070687bb065a7d43df70c9651375","url":"https://api.github.com/users/benwah","login":"benwah","id":165929},"milestone":null,"assignee":null,"labels":[],"updated_at":"2011-11-01T20:05:21Z","comments":2,"closed_at":"2011-11-01T20:05:21Z","url":"https://api.github.com/repos/hmarr/mongoengine/issues/346","body":"I noticed that you cannot easily change the datatype and/or actual data returned by queryset.sum(), this is sometimes useful when writing a BaseField subclass for things like Currency.\r\n\r\nI added a \"aggregate_to_python\" method to BaseField. Any data returned by QuerySet.sum or QuerySet.average is passed to the field's aggregate_to_python method before being returned.\r\n\r\nI also added a few lines to mongoengine/tests/queryset.py that ensures the proper behaviour for custom fields with a aggregate_to_python method.","html_url":"https://github.com/hmarr/mongoengine/issues/346","number":346,"title":"Add a aggregate_to_python method to BaseField, which allows customization of the data returned by QuerySet.sum and QuerySet.average","id":2114368,"created_at":"2011-11-01T20:00:07Z"},"action":"created","comment":{"user":{"avatar_url":"https://secure.gravatar.com/avatar/dab3070687bb065a7d43df70c9651375?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"dab3070687bb065a7d43df70c9651375","url":"https://api.github.com/users/benwah","login":"benwah","id":165929},"updated_at":"2011-11-01T20:05:21Z","url":"https://api.github.com/repos/hmarr/mongoengine/issues/comments/2595171","body":"Closing.. will re-open to merge into dev instead.","id":2595171,"created_at":"2011-11-01T20:05:21Z"}}