Skip to content

Commit 435f82a

Browse files
authored
Ecto 2.2.2 compatibility. (#198)
* Update references to point to Ecto 2.2.2. * Advance to "Set foreign key type to same used on primary keys (#2204)" commit from 08 Sep 2017. Integration tests are broken at this commit. * Adapt for breaking API change WRT references. IMHO this was not an appropriate change for a double-dot release. * Require Ecto 2.2.2 and up. There was a breaking API change from 2.2.1 to 2.2.2.
1 parent 17f39db commit 435f82a

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ defmodule Sqlite.Ecto2.Mixfile do
3939
{:dogma, "~> 0.1", only: :dev},
4040
{:esqlite, "~> 0.2.3"},
4141
{:ex_doc, "~> 0.16", only: :dev},
42-
{:ecto, "~> 2.2.0"},
42+
{:ecto, "~> 2.2.2"},
4343
{:poison, "~> 2.2 or ~> 3.0", optional: true},
4444
{:postgrex, "~> 0.13.0", optional: true},
4545
{:sbroker, "~> 1.0"},

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"decimal": {:hex, :decimal, "1.4.0", "fac965ce71a46aab53d3a6ce45662806bdd708a4a95a65cde8a12eb0124a1333", [:mix], [], "hexpm"},
88
"dogma": {:hex, :dogma, "0.1.15", "5bceba9054b2b97a4adcb2ab4948ca9245e5258b883946e82d32f785340fd411", [:mix], [{:poison, ">= 2.0.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
99
"earmark": {:hex, :earmark, "1.2.2", "f718159d6b65068e8daeef709ccddae5f7fdc770707d82e7d126f584cd925b74", [:mix], [], "hexpm"},
10-
"ecto": {:hex, :ecto, "2.2.1", "ccc6fd304f9bb785f2c3cfd0ee8da6bad6544ab12ca5f7162b20a743d938417c", [], [{: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"},
10+
"ecto": {:hex, :ecto, "2.2.2", "e9bd6ebc044eaaab1cb369e3465686d8aca830aa5bf545ef2bae000a3d42c54b", [], [{: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"},
1111
"esqlite": {:hex, :esqlite, "0.2.3", "1a8b60877fdd3d50a8a84b342db04032c0231cc27ecff4ddd0d934485d4c0cd5", [:rebar3], [], "hexpm"},
1212
"ex_doc": {:hex, :ex_doc, "0.16.3", "cd2a4cfe5d26e37502d3ec776702c72efa1adfa24ed9ce723bb565f4c30bd31a", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},
1313
"hackney": {:hex, :hackney, "1.7.1", "e238c52c5df3c3b16ce613d3a51c7220a784d734879b1e231c9babd433ac1cb4", [:rebar3], [{:certifi, "1.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "4.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},

test/sqlite_ecto_test.exs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -802,8 +802,9 @@ defmodule Sqlite.Ecto2.Test do
802802

803803
# DDL
804804

805-
import Ecto.Migration, only: [table: 1, table: 2, index: 2, index: 3, references: 1,
806-
references: 2, constraint: 2, constraint: 3]
805+
alias Ecto.Migration.Reference
806+
import Ecto.Migration, only: [table: 1, table: 2, index: 2, index: 3,
807+
constraint: 2, constraint: 3]
807808

808809
test "executing a string during migration" do
809810
assert execute_ddl("example") == ["example"]
@@ -874,7 +875,7 @@ defmodule Sqlite.Ecto2.Test do
874875

875876
test "create table with prefix" do
876877
create = {:create, table(:posts, prefix: :foo),
877-
[{:add, :category_0, references(:categories), []}]}
878+
[{:add, :category_0, %Reference{table: :categories}, []}]}
878879

879880
assert execute_ddl(create) == ["""
880881
CREATE TABLE "foo"."posts"
@@ -885,7 +886,7 @@ defmodule Sqlite.Ecto2.Test do
885886
test "create table with comment on columns and table" do
886887
create = {:create, table(:posts, comment: "comment"),
887888
[
888-
{:add, :category_0, references(:categories), [comment: "column comment"]},
889+
{:add, :category_0, %Reference{table: :categories}, [comment: "column comment"]},
889890
{:add, :created_at, :timestamp, []},
890891
{:add, :updated_at, :timestamp, [comment: "column comment 2"]}
891892
]}
@@ -898,7 +899,7 @@ defmodule Sqlite.Ecto2.Test do
898899

899900
test "create table with comment on table" do
900901
create = {:create, table(:posts, comment: "table comment"),
901-
[{:add, :category_0, references(:categories), []}]}
902+
[{:add, :category_0, %Reference{table: :categories}, []}]}
902903
assert execute_ddl(create) == [remove_newlines("""
903904
CREATE TABLE "posts"
904905
("category_0" INTEGER CONSTRAINT "posts_category_0_fkey" REFERENCES "categories"("id"))
@@ -909,7 +910,7 @@ defmodule Sqlite.Ecto2.Test do
909910
test "create table with comment on columns" do
910911
create = {:create, table(:posts),
911912
[
912-
{:add, :category_0, references(:categories), [comment: "column comment"]},
913+
{:add, :category_0, %Reference{table: :categories}, [comment: "column comment"]},
913914
{:add, :created_at, :timestamp, []},
914915
{:add, :updated_at, :timestamp, [comment: "column comment 2"]}
915916
]}
@@ -923,15 +924,15 @@ defmodule Sqlite.Ecto2.Test do
923924
test "create table with references" do
924925
create = {:create, table(:posts),
925926
[{:add, :id, :serial, [primary_key: true]},
926-
{:add, :category_0, references(:categories), []},
927-
{:add, :category_1, references(:categories, name: :foo_bar), []},
928-
{:add, :category_2, references(:categories, on_delete: :nothing), []},
929-
{:add, :category_3, references(:categories, on_delete: :delete_all), [null: false]},
930-
{:add, :category_4, references(:categories, on_delete: :nilify_all), []},
931-
{:add, :category_5, references(:categories, on_update: :nothing), []},
932-
{:add, :category_6, references(:categories, on_update: :update_all), [null: false]},
933-
{:add, :category_7, references(:categories, on_update: :nilify_all), []},
934-
{:add, :category_8, references(:categories, on_delete: :nilify_all, on_update: :update_all), [null: false]}]}
927+
{:add, :category_0, %Reference{table: :categories}, []},
928+
{:add, :category_1, %Reference{table: :categories, name: :foo_bar}, []},
929+
{:add, :category_2, %Reference{table: :categories, on_delete: :nothing}, []},
930+
{:add, :category_3, %Reference{table: :categories, on_delete: :delete_all}, [null: false]},
931+
{:add, :category_4, %Reference{table: :categories, on_delete: :nilify_all}, []},
932+
{:add, :category_5, %Reference{table: :categories, on_update: :nothing}, []},
933+
{:add, :category_6, %Reference{table: :categories, on_update: :update_all}, [null: false]},
934+
{:add, :category_7, %Reference{table: :categories, on_update: :nilify_all}, []},
935+
{:add, :category_8, %Reference{table: :categories, on_delete: :nilify_all, on_update: :update_all}, [null: false]}]}
935936

936937
assert execute_ddl(create) == ["""
937938
CREATE TABLE "posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -950,11 +951,11 @@ defmodule Sqlite.Ecto2.Test do
950951
test "create table with references including prefixes" do
951952
create = {:create, table(:posts, prefix: :foo),
952953
[{:add, :id, :serial, [primary_key: true]},
953-
{:add, :category_0, references(:categories, prefix: :foo), []},
954-
{:add, :category_1, references(:categories, name: :foo_bar, prefix: :foo), []},
955-
{:add, :category_2, references(:categories, on_delete: :nothing, prefix: :foo), []},
956-
{:add, :category_3, references(:categories, on_delete: :delete_all, prefix: :foo), [null: false]},
957-
{:add, :category_4, references(:categories, on_delete: :nilify_all, prefix: :foo), []}]}
954+
{:add, :category_0, %Reference{table: :categories}, []},
955+
{:add, :category_1, %Reference{table: :categories, name: :foo_bar}, []},
956+
{:add, :category_2, %Reference{table: :categories, on_delete: :nothing}, []},
957+
{:add, :category_3, %Reference{table: :categories, on_delete: :delete_all}, [null: false]},
958+
{:add, :category_4, %Reference{table: :categories, on_delete: :nilify_all}, []}]}
958959

959960
assert execute_ddl(create) == ["""
960961
CREATE TABLE "foo"."posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -1047,7 +1048,7 @@ defmodule Sqlite.Ecto2.Test do
10471048
test "alter table" do
10481049
alter = {:alter, table(:posts),
10491050
[{:add, :title, :string, [default: "Untitled", size: 100, null: false]},
1050-
{:add, :author_id, references(:author), []}]}
1051+
{:add, :author_id, %Reference{table: :author}, []}]}
10511052
assert execute_ddl(alter) == [
10521053
remove_newlines(~s|ALTER TABLE "posts" ADD COLUMN "title" TEXT DEFAULT 'Untitled' NOT NULL|),
10531054
remove_newlines(~s|ALTER TABLE "posts" ADD COLUMN "author_id" INTEGER CONSTRAINT "posts_author_id_fkey" REFERENCES "author"("id")|)]
@@ -1065,7 +1066,7 @@ defmodule Sqlite.Ecto2.Test do
10651066
test "alter table with prefix" do
10661067
alter = {:alter, table(:posts, prefix: :foo),
10671068
[{:add, :title, :string, [default: "Untitled", size: 100, null: false]},
1068-
{:add, :author_id, references(:author, prefix: :foo), []}]}
1069+
{:add, :author_id, %Reference{table: :author}, []}]}
10691070

10701071
assert execute_ddl(alter) == [
10711072
remove_newlines(~s|ALTER TABLE "foo"."posts" ADD COLUMN "title" TEXT DEFAULT 'Untitled' NOT NULL|),

0 commit comments

Comments
 (0)