fix: bind role_name variable before using in Ash.Query.filter
Avoid macro pinning issues by binding role_data.name to role_name before using it in the filter query.
This commit is contained in:
parent
35fbfe54da
commit
e906f22c4d
1 changed files with 4 additions and 1 deletions
|
|
@ -166,8 +166,11 @@ role_configs = [
|
||||||
|
|
||||||
# Create or update each role
|
# Create or update each role
|
||||||
Enum.each(role_configs, fn role_data ->
|
Enum.each(role_configs, fn role_data ->
|
||||||
|
# Bind role name to variable to avoid issues with ^ pinning in macros
|
||||||
|
role_name = role_data.name
|
||||||
|
|
||||||
case Mv.Authorization.Role
|
case Mv.Authorization.Role
|
||||||
|> Ash.Query.filter(name == ^role_data.name)
|
|> Ash.Query.filter(name == ^role_name)
|
||||||
|> Ash.read_one(authorize?: false, domain: Mv.Authorization) do
|
|> Ash.read_one(authorize?: false, domain: Mv.Authorization) do
|
||||||
{:ok, existing_role} when not is_nil(existing_role) ->
|
{:ok, existing_role} when not is_nil(existing_role) ->
|
||||||
# Role exists - update if needed (preserve is_system_role)
|
# Role exists - update if needed (preserve is_system_role)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue