Git Product home page Git Product logo

Comments (3)

kipcole9 avatar kipcole9 commented on July 19, 2024 1

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.

kipcole9 avatar kipcole9 commented on July 19, 2024 1

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.

kipcole9 avatar kipcole9 commented on July 19, 2024

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)

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.