Git Product home page Git Product logo

Comments (7)

mjquinlan2000 avatar mjquinlan2000 commented on August 19, 2024

I see you've been talking to Jose about this here elixir-ecto/ecto#3558

Closing.

from money_sql.

mjquinlan2000 avatar mjquinlan2000 commented on August 19, 2024

Also mentioned here #12

from money_sql.

kipcole9 avatar kipcole9 commented on August 19, 2024

@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.

kipcole9 avatar kipcole9 commented on August 19, 2024

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.

mjquinlan2000 avatar mjquinlan2000 commented on August 19, 2024

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.

kipcole9 avatar kipcole9 commented on August 19, 2024

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.

mjquinlan2000 avatar mjquinlan2000 commented on August 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.