diff --git a/.formatter.exs b/.formatter.exs index 2c92b21b..9da5523f 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -31,7 +31,6 @@ locals_without_parens = [ read: 2, resource: 1, resource: 2, - reverse_relationship: 1, source_field: 1, source_field_on_join_table: 1, through: 1, diff --git a/lib/ash/resource/relationships/belongs_to.ex b/lib/ash/resource/relationships/belongs_to.ex index 38450894..8dbb1b61 100644 --- a/lib/ash/resource/relationships/belongs_to.ex +++ b/lib/ash/resource/relationships/belongs_to.ex @@ -9,7 +9,6 @@ defmodule Ash.Resource.Relationships.BelongsTo do :destination_field, :source_field, :source, - :reverse_relationship, cardinality: :one, type: :belongs_to ] diff --git a/lib/ash/resource/relationships/has_many.ex b/lib/ash/resource/relationships/has_many.ex index e4c06254..861a0375 100644 --- a/lib/ash/resource/relationships/has_many.ex +++ b/lib/ash/resource/relationships/has_many.ex @@ -6,7 +6,6 @@ defmodule Ash.Resource.Relationships.HasMany do :destination_field, :source_field, :source, - :reverse_relationship, cardinality: :many, type: :has_many ] @@ -19,8 +18,7 @@ defmodule Ash.Resource.Relationships.HasMany do type: Ash.Type.t(), destination: Ash.resource(), destination_field: atom, - source_field: atom, - reverse_relationship: atom() | nil + source_field: atom } import Ash.Resource.Relationships.SharedOptions diff --git a/lib/ash/resource/relationships/has_one.ex b/lib/ash/resource/relationships/has_one.ex index c59530c4..ad841369 100644 --- a/lib/ash/resource/relationships/has_one.ex +++ b/lib/ash/resource/relationships/has_one.ex @@ -6,7 +6,6 @@ defmodule Ash.Resource.Relationships.HasOne do :destination, :destination_field, :source_field, - :reverse_relationship, :allow_orphans?, cardinality: :one, type: :has_one @@ -21,8 +20,7 @@ defmodule Ash.Resource.Relationships.HasOne do destination: Ash.resource(), destination_field: atom, source_field: atom, - allow_orphans?: boolean, - reverse_relationship: atom | nil + allow_orphans?: boolean } import Ash.Resource.Relationships.SharedOptions diff --git a/lib/ash/resource/relationships/many_to_many.ex b/lib/ash/resource/relationships/many_to_many.ex index 81709dfb..a140f9ee 100644 --- a/lib/ash/resource/relationships/many_to_many.ex +++ b/lib/ash/resource/relationships/many_to_many.ex @@ -9,7 +9,6 @@ defmodule Ash.Resource.Relationships.ManyToMany do :destination_field, :source_field_on_join_table, :destination_field_on_join_table, - :reverse_relationship, cardinality: :many, type: :many_to_many ] @@ -24,8 +23,7 @@ defmodule Ash.Resource.Relationships.ManyToMany do source_field: atom, destination_field: atom, source_field_on_join_table: atom, - destination_field_on_join_table: atom, - reverse_relationship: atom + destination_field_on_join_table: atom } import Ash.Resource.Relationships.SharedOptions diff --git a/lib/ash/resource/relationships/shared_options.ex b/lib/ash/resource/relationships/shared_options.ex index e97fef05..a108c94b 100644 --- a/lib/ash/resource/relationships/shared_options.ex +++ b/lib/ash/resource/relationships/shared_options.ex @@ -19,11 +19,6 @@ defmodule Ash.Resource.Relationships.SharedOptions do type: :atom, doc: "The field on this resource that should match the `destination_field` on the related resource." - ], - reverse_relationship: [ - type: :atom, - doc: - "A requirement for side loading data. Must be the name of an inverse relationship on the destination resource." ] ] diff --git a/test/actions/create_test.exs b/test/actions/create_test.exs index dbadf312..56392ac9 100644 --- a/test/actions/create_test.exs +++ b/test/actions/create_test.exs @@ -70,9 +70,7 @@ defmodule Ash.Test.Actions.CreateTest do relationships do has_one :profile, Profile, destination_field: :author_id - has_many :posts, Ash.Test.Actions.CreateTest.Post, - reverse_relationship: :author, - destination_field: :author + has_many :posts, Ash.Test.Actions.CreateTest.Post, destination_field: :author end end @@ -133,8 +131,7 @@ defmodule Ash.Test.Actions.CreateTest do many_to_many :related_posts, __MODULE__, through: PostLink, source_field_on_join_table: :source_post_id, - destination_field_on_join_table: :destination_post_id, - reverse_relationship: :related_posts + destination_field_on_join_table: :destination_post_id end end diff --git a/test/actions/side_load_test.exs b/test/actions/side_load_test.exs index 4142d77e..a297fedc 100644 --- a/test/actions/side_load_test.exs +++ b/test/actions/side_load_test.exs @@ -25,9 +25,7 @@ defmodule Ash.Test.Actions.SideLoadTest do end relationships do - has_many :posts, Ash.Test.Actions.SideLoadTest.Post, - reverse_relationship: :author, - destination_field: :author_id + has_many :posts, Ash.Test.Actions.SideLoadTest.Post, destination_field: :author_id end end @@ -53,7 +51,7 @@ defmodule Ash.Test.Actions.SideLoadTest do end relationships do - belongs_to :author, Author, reverse_relationship: :posts + belongs_to :author, Author many_to_many :categories, Module.concat(outer_mod, Category), through: Module.concat(outer_mod, PostCategory), diff --git a/test/actions/update_test.exs b/test/actions/update_test.exs index a7b71038..48f43b6b 100644 --- a/test/actions/update_test.exs +++ b/test/actions/update_test.exs @@ -69,9 +69,7 @@ defmodule Ash.Test.Actions.UpdateTest do relationships do has_one :profile, Profile, destination_field: :author_id - has_many :posts, Ash.Test.Actions.UpdateTest.Post, - reverse_relationship: :author, - destination_field: :author_id + has_many :posts, Ash.Test.Actions.UpdateTest.Post, destination_field: :author_id end end @@ -122,8 +120,7 @@ defmodule Ash.Test.Actions.UpdateTest do many_to_many :related_posts, __MODULE__, through: PostLink, source_field_on_join_table: :source_post_id, - destination_field_on_join_table: :destination_post_id, - reverse_relationship: :related_posts + destination_field_on_join_table: :destination_post_id end end diff --git a/test/filter/filter_test.exs b/test/filter/filter_test.exs index 4bfc463a..851ed364 100644 --- a/test/filter/filter_test.exs +++ b/test/filter/filter_test.exs @@ -49,13 +49,9 @@ defmodule Ash.Test.Filter.FilterTest do end relationships do - has_many :posts, Ash.Test.Filter.FilterTest.Post, - reverse_relationship: :author1, - destination_field: :author1_id + has_many :posts, Ash.Test.Filter.FilterTest.Post, destination_field: :author1_id - has_many :second_posts, Ash.Test.Filter.FilterTest.Post, - reverse_relationship: :author2, - destination_field: :author1_id + has_many :second_posts, Ash.Test.Filter.FilterTest.Post, destination_field: :author1_id has_one :profile, Profile, destination_field: :user_id end @@ -117,8 +113,7 @@ defmodule Ash.Test.Filter.FilterTest do many_to_many :related_posts, __MODULE__, through: PostLink, source_field_on_join_table: :source_post_id, - destination_field_on_join_table: :destination_post_id, - reverse_relationship: :related_posts + destination_field_on_join_table: :destination_post_id end end diff --git a/test/resource/relationships/many_to_many_test.exs b/test/resource/relationships/many_to_many_test.exs index 8ada9435..ff06b4eb 100644 --- a/test/resource/relationships/many_to_many_test.exs +++ b/test/resource/relationships/many_to_many_test.exs @@ -36,8 +36,7 @@ defmodule Ash.Test.Resource.Relationships.ManyToManyTest do name: :related_posts_join_assoc, source: Ash.Test.Resource.Relationships.ManyToManyTest.Post, source_field: :id, - type: :has_many, - reverse_relationship: nil + type: :has_many }, %Ash.Resource.Relationships.ManyToMany{ cardinality: :many, @@ -49,8 +48,7 @@ defmodule Ash.Test.Resource.Relationships.ManyToManyTest do source_field: :id, source_field_on_join_table: :post_id, through: SomeResource, - type: :many_to_many, - reverse_relationship: nil + type: :many_to_many } ] = Ash.relationships(Post) end