Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Ecto v3.4.2 and rewrite ExAudit.Repo to extend Ecto.Repo #36

Merged
merged 2 commits into from
Apr 20, 2020

Conversation

hisapy
Copy link
Contributor

@hisapy hisapy commented Apr 19, 2020

This is a breaking change to support ecto and ecto_sql ~> 3.4 and at the
same time to actually use ExAudit.Repo with Ecto.Repo.

The Ecto.Repo @callback implementations are overriden to add version tracking if the
given struct or changeset is in the list of :tracked_schemas specified in the config
or call the original Ecto.Repo implementation otherwise.

This is a breaking change to support ecto and ecto_sql ~> 3.4 and at the
same time to actually use ExAudit.Repo with Ecto.Repo.

The Ecto.Repo @callback implementations are overriden to add version tracking if the
given struct or changeset is in the list of :tracked_schemas specified in the config
or call the original Ecto.Repo implementation otherwise.
* Tracks associated entities when they're created, updated or deleted in a single Repo call
* Recursively tracks cascading deletions

- Wraps Ecto.Repo, no need to change your existing codebase to start tracking changes
Copy link
Contributor Author

@hisapy hisapy Apr 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My IDE did this changes (- instead of *) automatically when I saved the file. I hope you don't mind 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this reformating makes it really hard to see what you actually changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't know why my VS Code formatter changed those.

@narrowtux
Copy link
Contributor

I like what you did there, especially that we don't need to reimplement all repo functions any more.

@narrowtux narrowtux closed this Apr 20, 2020
@narrowtux narrowtux reopened this Apr 20, 2020
@narrowtux narrowtux merged commit 7d9434b into ZennerIoT:master Apr 20, 2020
@hisapy
Copy link
Contributor Author

hisapy commented Apr 20, 2020

Yeah, I upgraded Ecto and started using Oban and got the debug log from the queues outputted in the console when they shouldn't so I replied a similar issue and the maintainer told me that it might be something with prepare_query.

So after digging around I realized that it'd be better to avoid rewriting the whole Ecto.Repo @callback implementations to make ExAudit more easy to maintain with respect to Ecto upgrades and after a couple of days and designs I came up with this solution.

Thx for this lib. I like it because of the clever way of auditing transparently and supporting assocs using the children traversal logic that is already implemented in Ecto.Repo.Schema.

@yukster
Copy link
Contributor

yukster commented May 7, 2020

@narrowtux any chance we could get a new release? I have a working integration based off master (using Ecto 3.4.2) but I'd rather not leave it that way if I can change to a tag.

@yukster
Copy link
Contributor

yukster commented May 8, 2020

Duh, I can just use the :ref option. Still, working with 3.4 is a big deal and seems worth a release.

BTW, nice work on this lib! It's slick.

@cleveyeo
Copy link

cleveyeo commented Aug 7, 2020

Is there going to be a new release? am in need of this to work with Ecto 3.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants