fix: remove reverse relationships

This commit is contained in:
Zach Daniel 2020-06-22 00:34:44 -04:00
parent f136ddcad7
commit c89acce635
No known key found for this signature in database
GPG key ID: C377365383138D4B
11 changed files with 14 additions and 42 deletions

View file

@ -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,

View file

@ -9,7 +9,6 @@ defmodule Ash.Resource.Relationships.BelongsTo do
:destination_field,
:source_field,
:source,
:reverse_relationship,
cardinality: :one,
type: :belongs_to
]

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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."
]
]

View file

@ -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

View file

@ -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),

View file

@ -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

View file

@ -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

View file

@ -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