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

Allow named operations for compatibility with Ecto.Multi #75

Merged
merged 6 commits into from
Mar 29, 2020
Merged

Allow named operations for compatibility with Ecto.Multi #75

merged 6 commits into from
Mar 29, 2020

Conversation

marioimr
Copy link
Contributor

If you're willing to accept it this allows to add a suffix, which defaults to empty string, called "index" in the options so to permit wrapping in a single transactions more operations

@izelnakri
Copy link
Owner

Hi @marioimr, thanks for your contribution! Could you run the elixir formatter on the your changes?

Also as it seems CI is not running currently on forked repo. I'll pull and run the tests locally and my initial impression is this is something we can merge. I'll give another consideration soon, thanks again.

) do
model = String.to_atom("model" <> options[:index])
version = String.to_atom("version" <> options[:index])
Copy link
Owner

Choose a reason for hiding this comment

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

Although I see that these variables wont clash with the model and version references below, it is still in my opinion better to name them differently such as model_key, version_key.

Also it might be a better idea to not have these variables and have them in the options with default values being "model", and "version" instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@izelnakri thanks to you for the library in the first place and for considering my PR.

You're right, it does sound better the naming you suggest, I'll change it shortly, but AFAIK (forgive me I'm a rookie in Elixir) I can't use the ^ for pattern matching with something like options[:model], so I'll keep at least the model variable.

I also ran mix format but it didn't change anything.

options \\ [origin: nil, meta: nil, originator: nil, prefix: nil]
) do
def insert(%Ecto.Multi{} = multi, changeset, options \\ [origin: nil, meta: nil, originator: nil, prefix: nil, model_key: :model, version_key: :version]) do
model = options[:model_key]
Copy link
Owner

Choose a reason for hiding this comment

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

we can merge this after renaming this to model_key. Thanks!

@izelnakri izelnakri merged commit a9aa570 into izelnakri:master Mar 29, 2020
@izelnakri
Copy link
Owner

Hi @marioimr, I've merged the PR but tests are failing locally. I'm not going to cut a release unless we fix the tests. Investigating why they are failing now.

@izelnakri
Copy link
Owner

this merge introduced a bug on PaperTrail.insert and PaperTrail.insert! APIs, its fixed on this commit: 058a84f

I'll cut a 0.8.7 release in few minutes after dependency upgrades.

@marioimr
Copy link
Contributor Author

@izelnakri thank you for the update and the fix! Cheers :-)

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.

None yet

2 participants