Calculation delegating on Association

Alan Francis wrote:

def task_estimate

Now, the first assert passes, so I figure I'm using 'sum' properly. The
second assert fails saying expected 0, got nil.

There's definitely a bug in Active Record that causes empty sums
to be returned as nil rather than 0. The Calculations module casts
the nil result to to the column's type, but this casting always returns
nil for a nil parameter.

I thought I'd found a bug, in summing a collection with no elements, and
right enough there's no test for that in ActiveRecord, but when I do the
following in the console:


I get 0 as expected. So as best I can tell I get nil when summing an
empty association during testing, but not in the console.

That's strange, I always get nil.