ZennerIoT / ex_audit

Ecto auditing library that transparently tracks changes and can revert them.
MIT License
368 stars 110 forks source link

default_options/1 can't be overridden #74

Closed MMore closed 3 years ago

MMore commented 3 years ago

Hello,

I've defined in MyApp.Repo the function default_options/1. Unfortunately ExAudit prevents overriding that function. At least it's not used. When I replace

    defmodule MyApp.Repo  do
      use ExAudit.Repo

by

    defmodule MyApp.Repo do
      use Ecto.Repo

it's working correctly.

Moreover when compiling the ExAudit dependency I get warning: conflicting behaviours found. function default_options/1 is required by Ecto.Repo and ExAudit.Repo (in module MyApp.Repo).

bringking commented 3 years ago

Bumping this. We are seeing the same warning using ecto 3.6 and ex_audit 0.9. Any suggest resolution here?

MMore commented 3 years ago

I made some changes in #75 and I am using that as a dependency right now until it's in master/main. It's working fine for me.

MMore commented 3 years ago

The world changed a little bit. The state of the master branch was updated to work with current Ecto versions. Before edge was used. In master the approach using the library is different:

defmodule MyApp.Repo do
  use Ecto.Repo,
    otp_app: :my_app,
    adapter: Ecto.Adapters.Postgres

  use ExAudit.Repo
end

Before, in edge it was:

defmodule MyApp.Repo do
  use ExAudit.Repo,
    otp_app: :my_app,
    adapter: Ecto.Adapters.Postgres
end

So now in master ExAudit isn't replacing the whole Repo anymore but extending it which means features like default_options/1 are available automatically. Not necessary to add it anymore. The only remaining problem was basically a warning which is fixed with #78.

For some more context about the strange merge behaviour of the maintainer, see #75.