Closed kipcole9 closed 2 years ago
On reflection I suspect this is not a fruitful path to explore.
The current SUM
function skips NULL rows (because it is STRICT) and returns NULL
if there are no non-NULL values. This is consistent with expectations of the SUM
function.
In the case where no rows have non-NULL values then the money amount can be set to zero, but its not possible to set the currency code.
Therefore there is no practical path to return a zero money in the aggregate function.
It may be possible to set a default on the Ecto type :money_with_currency
since its a parameterised type. I'll close this issue for now, feel free to re-open if you see an alternative approach.
@sergiotapia has expressed interest in aggregating
NULL
values as zero-amount money.The current aggregate function is
STRICT
meaning thatNULL
values are not processed. In some cases it is desirable to return a zero-amount money rather than NULL.Changing the current function to remove
STRICT
may have unexpected results and therefore a new function that explicitly has this behaviour may be required.