Comments (7)
I see you've been talking to Jose about this here elixir-ecto/ecto#3558
Closing.
from money_sql.
Also mentioned here #12
from money_sql.
@mjquinlan2000, thanks for raising the issue. As you found, this is fixed on Ecto master but not yet released on Hex. Nevertheless, you remind me I need to update documentation to note that using the type/2
macro is a different for a parameterised type versus one that is not.
from money_sql.
Just looking at your query, are you sure you need to cast the type there? Usually it only needs to be cast when there are aggregate functions involved. Otherwise its type detection is pretty good, especially when using a schema as you are. ie does the following work?
MyModel
|> select([m], %{money: m.money})
from money_sql.
The actual query is in production code which is both very complex and proprietary so I can't really share it. I reduced it to the simplest query that would produce the error. I am just going to wait until type(t, {:parametarized, Money.Ecto.Composite.Type, []})
is out on Ecto
from money_sql.
Ah, ok, thanks for the update. Make sense.
I have just added Money.Ecto.Composite.Type.cast_type/{0, 1}
make the transition as easy as possible but this is clearly a breaking change in Ecto that I wasn't aware of. I would have made this a new type if I had known and I will send a PR for the ecto docs to make that clearer for others.
Any thoughts on how to handle the situation? I should have made this a major release but thats too late now.
Would creating a new type that is non-parameterised (ie same as the old behaviour) help you in this case?
from money_sql.
To be honest, the proposal on elixir-ecto/ecto#3558 (specifying parameterized in the type/2 call) seems like a messy contract.
In my opinion, Ecto.ParametarizedType should enforce a type/0 callback as well or figure out how to pass empty opts when no {:parameterized, Type, opts}
tuple is passed to type/2
In addition, I would get rid of the type/2
implementation of using parameterized types and create a new parameterized_type/3
function in Ecto.Query.API that looks something like this parameterized_type(t, Money.Ecto.Composite.Type, opts)
so that the contract is explicitly defined by the function name and not the pattern of the arguments.
However, I don't think there's anything to be done in this library so I can just wait for a new version of Ecto
from money_sql.
Related Issues (20)
- `undefined function migrations_path/1` when attempting to compile HOT 3
- 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
- Unmatched clause for `Cldr.Decimal.parse/1` HOT 1
- Composite type cast does not respect locales HOT 5
- Possible bug in ecto? Asking here first for clarification HOT 3
- Broken/Unsupported CompositeType defaults
- Checking if I receive notifications
- Getting `type/0` is undefined errors when upgrading HOT 6
- 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
- Money.Ecto.Map.Type.embed_as/2 should return :dump instead of :self HOT 2
- Protocol.UndefinedError exception for Jason.Encoder when embedded schema is configured incorrectly with Money.Ecto.Composite.Type HOT 8
- Sum returns ERROR 42804 (datatype_mismatch) HOT 7
- Could not read file error after upgrading to 1.10.0 HOT 4
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.