Problem
I modified a table's 'amount_in_cents' column to be the PostgreSQL type bigint rather than integer. This seems to have caused calls using Repo.aggregate calls to fail to load the result type into a Money struct.
schema "adjustments" do
field :amount_in_cents, Money.Ecto.Amount.Type
# ...
end
#
query = from(a in Adjustment, where a.wallet_id == ^wallet_id)
Repo.aggregate(query, :sum, :amount_in_cents)
This results in the following issue.
I'm not totally sure why aggregate changes it's return type from an integer to a Decimal.
This causes Money.Ecto.Amount.Type.load/1 to fail to match.
Proposed Solution
Add a new function head to the load function.
Problem I modified a table's 'amount_in_cents' column to be the PostgreSQL type
bigint
rather thaninteger
. This seems to have caused calls using Repo.aggregate calls to fail to load the result type into a Money struct.This results in the following issue.
I'm not totally sure why aggregate changes it's return type from an integer to a Decimal. This causes
Money.Ecto.Amount.Type.load/1
to fail to match.Proposed Solution Add a new function head to the load function.