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 ExMachina.Ecto to be used without the :repo option #370

Merged
merged 3 commits into from
Dec 3, 2019

Conversation

col
Copy link
Contributor

@col col commented Nov 17, 2019

We should be able to use Ecto without a repo. This is useful when using ecto without ecto_sql.

ExMachina currently raising an ArgumentError when using ExMachina.Ecto without a repo. This change now allows the repo to be nil and raises a RuntimeError when the insert/1 function is called instead.

New error message should still be helpful enough for people that simply forgot to add the :repo option.

insert/1 is not available unless you provide the :repo option. Example:

use ExMachina.Ecto, repo: MyApp.Repo

I believe this addresses the following issues:
#369
#355

@germsvel
Copy link
Collaborator

@col thanks so much for opening up this PR! It looks really good.

I saw you added some tests for when we raise the error. Would you also be willing to add a couple of tests that ensure params_for and string_params_for work without the repo being passed in?

@col
Copy link
Contributor Author

col commented Nov 18, 2019

Sure will do.

@col
Copy link
Contributor Author

col commented Nov 18, 2019

@germsvel - Done. I kept the tests pretty basic. Let me know if you'd like the tests to cover anything else more specifically. Looks like the repo is only used by the ExMachina.EctoStrategy which only affects the insert functions.

@germsvel
Copy link
Collaborator

Thanks @col! I gave it a quick glance, and things look good. I'll give it a better look when I have a few more minutes, but I think this is probably good to merge.

@germsvel germsvel merged commit b2f47a3 into beam-community:master Dec 3, 2019
@germsvel
Copy link
Collaborator

germsvel commented Dec 3, 2019

This looks good! Thanks for the PR @col! 🎉

@col
Copy link
Contributor Author

col commented Dec 4, 2019

This looks good! Thanks for the PR @col! 🎉

You're welcome. Thanks for merging. 👍

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.

2 participants