256MbTeam/Redmine-Scrumbler — Issue #24: Error in Statistics (burndown) with postgresql DB
Author: danielplappert
Created: 2012-02-13 10:26:22+00:00
State: open

Using a postgresql DB causes an error in statistics:

```ruby
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
: select sum(value) from custom_values where
custom_values.custom_field_id = 10 and
custom_values.customized_type = 'Issue' and
custom_values.customized_id in (1405,0) and
custom_values.value <> '?'):
vendor/plugins/redmine_scrumbler/app/models/scrumbler_sprint.rb:63:in `points_total'
vendor/plugins/redmine_scrumbler/app/controllers/scrumbler_sprints_controller.rb:135:in `burndown_calc'
vendor/plugins/redmine_scrumbler/app/controllers/scrumbler_sprints_controller.rb:116:in `burndown'
```

This happens because the sum function in postgresql needs a conversion, if the value is not a number or numeric type. The correct query for postgresql would be:

```ruby
select sum(value::numeric) from custom_values where
custom_values.custom_field_id = 10 and
custom_values.customized_type = 'Issue' and
custom_values.customized_id in (1405,0) and
custom_values.value <> '?')
```