mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 05:23:03 +12:00
improvement: use cached to_tenant when setting tenant attribute (#1021)
This commit is contained in:
parent
7e277673fd
commit
3338b343ac
4 changed files with 4 additions and 8 deletions
|
@ -513,8 +513,7 @@ defmodule Ash.Actions.Create.Bulk do
|
|||
Ash.Resource.Info.multitenancy_strategy(changeset.resource) == :attribute do
|
||||
attribute = Ash.Resource.Info.multitenancy_attribute(changeset.resource)
|
||||
{m, f, a} = Ash.Resource.Info.multitenancy_parse_attribute(changeset.resource)
|
||||
tenant = Ash.ToTenant.to_tenant(changeset.tenant, changeset.resource)
|
||||
attribute_value = apply(m, f, [tenant | a])
|
||||
attribute_value = apply(m, f, [changeset.to_tenant | a])
|
||||
|
||||
Ash.Changeset.force_change_attribute(changeset, attribute, attribute_value)
|
||||
else
|
||||
|
|
|
@ -497,8 +497,7 @@ defmodule Ash.Actions.Create do
|
|||
Ash.Resource.Info.multitenancy_strategy(changeset.resource) == :attribute do
|
||||
attribute = Ash.Resource.Info.multitenancy_attribute(changeset.resource)
|
||||
{m, f, a} = Ash.Resource.Info.multitenancy_parse_attribute(changeset.resource)
|
||||
tenant = Ash.ToTenant.to_tenant(changeset.tenant, changeset.resource)
|
||||
attribute_value = apply(m, f, [tenant | a])
|
||||
attribute_value = apply(m, f, [changeset.to_tenant | a])
|
||||
|
||||
Ash.Changeset.force_change_attribute(changeset, attribute, attribute_value)
|
||||
else
|
||||
|
|
|
@ -1148,8 +1148,7 @@ defmodule Ash.Actions.Read do
|
|||
|
||||
if multitenancy_attribute && query.tenant do
|
||||
{m, f, a} = Ash.Resource.Info.multitenancy_parse_attribute(query.resource)
|
||||
tenant = Ash.ToTenant.to_tenant(query.tenant, query.resource)
|
||||
attribute_value = apply(m, f, [tenant | a])
|
||||
attribute_value = apply(m, f, [query.to_tenant | a])
|
||||
Ash.Query.filter(query, ^ref(multitenancy_attribute) == ^attribute_value)
|
||||
else
|
||||
query
|
||||
|
|
|
@ -581,8 +581,7 @@ defmodule Ash.Actions.Update do
|
|||
attribute = Ash.Resource.Info.multitenancy_attribute(changeset.resource)
|
||||
|
||||
{m, f, a} = Ash.Resource.Info.multitenancy_parse_attribute(changeset.resource)
|
||||
tenant = Ash.ToTenant.to_tenant(changeset.tenant, changeset.resource)
|
||||
attribute_value = apply(m, f, [tenant | a])
|
||||
attribute_value = apply(m, f, [changeset.to_tenant | a])
|
||||
|
||||
Ash.Changeset.force_change_attribute(changeset, attribute, attribute_value)
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue