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

Ecto 3.0 support #301

Merged
merged 4 commits into from Nov 2, 2018
Merged

Ecto 3.0 support #301

merged 4 commits into from Nov 2, 2018

Conversation

zillou
Copy link
Contributor

@zillou zillou commented Oct 22, 2018

Not sure about the plan for Ecto 3.0 support. But I tested against ecto_sql 3.0.0-rc1, and everything is working perfectly.

@germsvel
Copy link
Collaborator

Thanks for looking into this @zillou. I don't think we have any particular plans for Ecto 3 in terms of new features or anything like that. But soon after it is out, we can do what you're doing here and go with it.

mix.exs Outdated
@@ -36,8 +36,9 @@ defmodule ExMachina.Mixfile do
[
{:ex_doc, "~> 0.14", only: :dev},
{:earmark, ">= 0.0.0", only: :dev},
{:ecto, "~> 2.1", optional: true},
{:postgrex, ">= 0.0.0", only: [:test]},
{:ecto_sql, "~> 3.0.0-pre", optional: true},
Copy link

@archseer archseer Oct 29, 2018

Choose a reason for hiding this comment

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

ecto ~> 2.1 or ~> 3.0 would work too

Choose a reason for hiding this comment

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

agreed, that would definitely be preferred and it matches phoenix_ecto: https://github.com/phoenixframework/phoenix_ecto/blob/v3.5.0/mix.exs#L40

mix.exs Outdated
{:postgrex, ">= 0.0.0", only: [:test]},
{:ecto_sql, "~> 3.0.0-pre", optional: true},
{:jason, "~> 1.0", optional: true},
{:postgrex, "~> 0.14.0-pre", only: :test},

Choose a reason for hiding this comment

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

0.14.0 final is out as of today.

@zillou
Copy link
Contributor Author

zillou commented Oct 29, 2018

Thank you @archseer, @wojtekmach.

mix.exs Outdated
{:postgrex, ">= 0.0.0", only: [:test]},
{:ecto, "~> 2.2 or ~> 3.0", optional: true},
{:jason, "~> 1.0", optional: true},
{:ecto_sql, "~> 2.2 or ~> 3.0-pre", only: :test},
Copy link

Choose a reason for hiding this comment

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

ecto_sql 3.0 got released, so you can change 3.0-pre to 3.0.

Copy link

Choose a reason for hiding this comment

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

thanks @zillou.

@nathany
Copy link

nathany commented Nov 1, 2018

looks good to me

Copy link
Collaborator

@germsvel germsvel left a comment

Choose a reason for hiding this comment

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

Hi @zillou, thank you so much for taking the initiative to do this! I have a few questions, but overall this looks good!

{:ecto, "~> 2.1", optional: true},
{:postgrex, ">= 0.0.0", only: [:test]},
{:ecto, "~> 2.2 or ~> 3.0", optional: true},
{:jason, "~> 1.0", optional: true},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to include jason as part of upgrading to 3.0? If so, is it safe to remove poison?

Copy link

@wojtekmach wojtekmach Nov 2, 2018

Choose a reason for hiding this comment

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

Looking at code, Poison is only used in docs so I'd suggest to remove it from mix.exs and mix.lock and optionally promote Jason as it's recommended by Ecto & Phoenix.

{:ecto, "~> 2.2 or ~> 3.0", optional: true},
{:jason, "~> 1.0", optional: true},
{:ecto_sql, "~> 2.2 or ~> 3.0", only: :test},
{:postgrex, "~> 0.14.0", only: :test},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to update postgrex or is it fine to leave it as >= 0.0.0?

Copy link

Choose a reason for hiding this comment

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

>= 0.0.0 should work fine, ecto_sql will already lock it to whatever version it needs.

https://github.com/elixir-ecto/ecto_sql/blob/a11efc4e4d3a6a9025ca96894cb9f708a121d0fd/mix.exs#L52

@@ -36,8 +36,10 @@ defmodule ExMachina.Mixfile do
[
{:ex_doc, "~> 0.14", only: :dev},
{:earmark, ">= 0.0.0", only: :dev},
{:ecto, "~> 2.1", optional: true},
{:postgrex, ">= 0.0.0", only: [:test]},
{:ecto, "~> 2.2 or ~> 3.0", optional: true},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to keep this, or should we only be using {:ecto_sql, "~> 3.0"}? I think it was needed when working with release candidates, but now it should be fine to remove (as far as I understand).

I'm getting that idea from reading this blog post,

If you are using Ecto with a SQL database, migrating to Ecto 3.0 will be very straight-forward. Instead of:
{:ecto, "~> 2.2"}
You should list:
{:ecto_sql, "~> 3.0"}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I was not quite sure about which library we need to use in ExMachina. I just did a quick eyeballing of the codebase, I didn't find any code related to ecto_sql, so I chose ecto here.

I'll update the deps list if we do need ecto_sql.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will there be any chance that ExMachina is used in a project without a SQL database, with the same reason of the splition of Ecto.SQL?

Copy link

Choose a reason for hiding this comment

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

I would keep ecto as {:ecto, "~> 3.0"} and ecto_sql as {:ecto_sql, "~> 3.0", optional: true}, since you can technically use ex_machina to only build structs and not write to the DB. That said, I've had the same question in a few other dependencies where it's not as obvious.

{:postgrex, ">= 0.0.0", only: [:test]},
{:ecto, "~> 2.2 or ~> 3.0", optional: true},
{:jason, "~> 1.0", optional: true},
{:ecto_sql, "~> 2.2 or ~> 3.0", only: :test},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should ecto_sql have an optional: true here since ex_machina can be used without ecto?

Copy link

Choose a reason for hiding this comment

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

It's limited to only: test so it should work the same way

use Ecto.Repo, otp_app: :ex_machina
use Ecto.Repo,
otp_app: :ex_machina,
adapter: Ecto.Adapters.Postgres
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 good catch!

@hisapy
Copy link

hisapy commented Nov 2, 2018

I've just started a new project with Ecto 3 a few days ago and now I'm needing some factories to speed up my typing ...

Thanks a lot in advance for this and I hope it can be merged soon!

@germsvel
Copy link
Collaborator

germsvel commented Nov 2, 2018

@zillou thanks again for these changes! I took another look, and I think they're good. I had mentioned getting rid of poison, but I can do that in a separate commit.

@germsvel germsvel merged commit 8d67c25 into beam-community:master Nov 2, 2018
@zillou zillou deleted the ecto-3.0 branch November 3, 2018 04:04
germsvel pushed a commit that referenced this pull request Jan 20, 2019
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

6 participants