Ash FrameworkAF
Ash Frameworkโ€ข3w agoโ€ข
5 replies
Jesse Williams

calculation argument does not support expressions

I'm trying to build a calculation on a user resource that looks something like this:

expr(
  exists(
    organizations,
    manages_user(user_id: parent(id)) and
      (is_nil(^arg(:organization_id)) or id == ^arg(:organization_id))
  )
)


Where manages_user is a calculation containiung some complex expression logic I'd really like to avoid replicating in raw ecto if possible.

As it currently stands, this breaks on manages_user(user_id: parent(id)) with an error Invalid value provided for calculation argument user_id in manages_user: does not support expressions.

This seems like a fundamental limitation of expressions/calculations, but I'm wondering if anyone has any tips for working around this? Preferably without having to replicate my manages_user calculation logic in raw ecto ๐Ÿ˜… although I'm starting to think that might be the only way to approach this
Was this page helpful?