Skip to content

Not dumped values in telemetry events #463

@fuelen

Description

@fuelen

Elixir version

1.12.2

Database and Version

PostgreSQL 14.1

Ecto Versions

ecto 3.9.2, ecto_sql 3.9.1

Database Adapter and Versions (postgrex, myxql, etc)

postgrex 0.16.0

Current behavior

After updating ecto_sql from 3.9.0 to 3.9.1 I noticed one error in my test suit.
Possibly related to #455
As I understand, Ecto sends all arguments to telemetry, which are not dumped to native types.

if we have the following type

  defmodule Money.Ecto.Type do
    use Ecto.ParameterizedType

    def type(_params), do: :money_type

    def init(_opts), do: %{}

    def cast(_data, _params), do: {:ok, nil}

    def load(nil, _loader, _params), do: {:ok, nil}

    def load({currency, value}, _loader, _params),
      do: {:ok, %Money{currency: currency, value: value}}

    def dump(nil, _dumper, _params), do: {:ok, nil}
    def dump(data, _dumper, _params), do: {:ok, {data.currency, data.value}}

    def equal?(a, b, _params) do
      a == b
    end
  end

and try to insert a new record with the type above, then the value comes to telemetry as is - Money struct.

Expected behavior

Seems like current behaviour is a new feature, but for https://github.com/fuelen/ecto_dev_logger I'd like to have some way of having native types in order to print SQL counterpart.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions