Comments (3)
Turns out I can't work around this. Adding type/0
to the composite type seems to make Ecto think its a non-parameterised type and therefore other bad things happen.
from money_sql.
Confirmed it was an Ecto bug which is now fixed on the main branch. I confirmed is works in my tests.
I expect this will be fixed when Ecto 3.6 comes out. Until then, if there is no other way, I recommend you use ecto
directly from GitHub using:
# Your query should look like this
# init_options is either `[]` or a keyword list of options
# you would pass to the `:field` definition on an ecto
# schema
query =
from(
organization in "organizations",
select: %{
total: type(sum(organization.payroll),
^Ecto.ParameterizedType.init(Money.Ecto.Composite.Type, init_options)
)
}
)
# Which basically is the same as:
query =
from(
organization in "organizations",
select: %{
total: type(sum(organization.payroll),
^{:parameterized, Money.Ecto.Composite.Type, []}
)
}
)
# mix.exs
def deps do
...
{:ecto, github: "elixir-echo/ecto", override: true},
...
end
Closing this issue for now, let me know if there is anything else I can help with.
from money_sql.
Thats definitely curious and I wonder if it is indeed an Ecto bug. I'll do some digging. In the meantime I can workaround this since I need to push an update today for issue #14.
Thanks much for the issue and sorry for the inconvenience. Moving to a parameterised type has proved more problematic on edge cases than expected.
from money_sql.
Related Issues (17)
- Couldn't generate migration for custom type due to incorrect path HOT 5
- Unmatched clause for `Cldr.Decimal.parse/1` HOT 1
- Composite type cast does not respect locales HOT 5
- Broken/Unsupported CompositeType defaults
- Checking if I receive notifications
- function Money.Ecto.Composite.Type.type/0 is undefined or private when using Ecto.Query.Api.type/2 HOT 7
- Getting `type/0` is undefined errors when upgrading HOT 6
- `undefined function migrations_path/1` when attempting to compile HOT 3
- Add keyword list to error return from money_with_currency cast/1 HOT 3
- Add Ecto Changeset validations HOT 1
- Aggregate function treating null as zero amount HOT 1
- Is it able to change the behavior of to_string for `Money.Ecto.Composite.Type` ? HOT 7
- Cast function used to return error when currency is nil HOT 2
- Ecto types return malformed error when casting invalid currency HOT 2
- Dependencie issue with ex_money 5.2 HOT 2
- Not compatible with Decimal 2.0 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from money_sql.