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
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion config/test.exs
Expand Up @@ -3,7 +3,6 @@ use Mix.Config
config :ex_machina, ExMachina.TestRepo,
hostname: "localhost",
database: "ex_machina_test",
adapter: Ecto.Adapters.Postgres,
pool: Ecto.Adapters.SQL.Sandbox,
username: "postgres"

Expand Down
6 changes: 4 additions & 2 deletions mix.exs
Expand Up @@ -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.

{: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_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.

{: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

{:poison, "~> 3.0", only: :test}
]
end
Expand Down
17 changes: 11 additions & 6 deletions mix.lock
@@ -1,16 +1,21 @@
%{"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], []},
"db_connection": {:hex, :db_connection, "1.1.2", "2865c2a4bae0714e2213a0ce60a1b12d76a6efba0c51fbda59c9ab8d1accc7a8", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"},
"decimal": {:hex, :decimal, "1.4.0", "fac965ce71a46aab53d3a6ce45662806bdd708a4a95a65cde8a12eb0124a1333", [:mix], [], "hexpm"},
%{
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], []},
"db_connection": {:hex, :db_connection, "2.0.0", "e28c878035eec1b891e629555ddfed6456e43d8482340a81924da8c85eb6b8a1", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm"},
"decimal": {:hex, :decimal, "1.5.0", "b0433a36d0e2430e3d50291b1c65f53c37d56f83665b43d79963684865beab68", [:mix], [], "hexpm"},
"earmark": {:hex, :earmark, "1.2.6", "b6da42b3831458d3ecc57314dff3051b080b9b2be88c2e5aa41cd642a5b044ed", [:mix], [], "hexpm"},
"ecto": {:hex, :ecto, "2.1.6", "29b45f393c2ecd99f83e418ea9b0a2af6078ecb30f401481abac8a473c490f84", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"},
"ecto": {:hex, :ecto, "3.0.0", "059250d96f17f9c10f524fcb09d058f566691343e90318a161cf62a48f3912a9", [:mix], [{:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm"},
"ecto_sql": {:hex, :ecto_sql, "3.0.0-rc.0", "a61da743812a47174e8b79dbe6aa7d4a9f7e6dbf8c90cfd7015f3767738b37ba", [:mix], [{:db_connection, "~> 2.0-rc.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.0.0-rc.1", [hex: :ecto, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.9.0-rc.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.14.0-rc.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.2.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"},
"esqlite": {:hex, :esqlite, "0.2.1"},
"ex_doc": {:hex, :ex_doc, "0.19.1", "519bb9c19526ca51d326c060cb1778d4a9056b190086a8c6c115828eaccea6cf", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.7", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
"makeup": {:hex, :makeup, "0.5.1", "966c5c2296da272d42f1de178c1d135e432662eca795d6dc12e5e8787514edf7", [:mix], [{:nimble_parsec, "~> 0.2.2", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
"makeup_elixir": {:hex, :makeup_elixir, "0.8.0", "1204a2f5b4f181775a0e456154830524cf2207cf4f9112215c05e0b76e4eca8b", [:mix], [{:makeup, "~> 0.5.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 0.2.2", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
"nimble_parsec": {:hex, :nimble_parsec, "0.2.2", "d526b23bdceb04c7ad15b33c57c4526bf5f50aaa70c7c141b4b4624555c68259", [:mix], [], "hexpm"},
"pipe": {:hex, :pipe, "0.0.2"},
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], []},
"poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], []},
"postgrex": {:hex, :postgrex, "0.13.3", "c277cfb2a9c5034d445a722494c13359e361d344ef6f25d604c2353185682bfc", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm"},
"postgrex": {:hex, :postgrex, "0.14.0", "f3d6ffea1ca8a156e0633900a5338a3d17b00435227726baed8982718232b694", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"},
"sqlite_ecto": {:hex, :sqlite_ecto, "1.0.2"},
"sqlitex": {:hex, :sqlitex, "0.8.2"}}
"sqlitex": {:hex, :sqlitex, "0.8.2"},
"telemetry": {:hex, :telemetry, "0.2.0", "5b40caa3efe4deb30fb12d7cd8ed4f556f6d6bd15c374c2366772161311ce377", [:mix], [], "hexpm"},
}
2 changes: 1 addition & 1 deletion test/support/models/user.ex
Expand Up @@ -9,6 +9,6 @@ defmodule ExMachina.User do

has_many :articles, ExMachina.Article, foreign_key: :author_id
has_many :editors, through: [:articles, :editor]
has_one :best_article, ExMachina.Article
has_one :best_article, ExMachina.Article, foreign_key: :author_id
end
end
4 changes: 3 additions & 1 deletion test/support/test_repo.ex
@@ -1,3 +1,5 @@
defmodule ExMachina.TestRepo do
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!

end