Ash FrameworkAF
Ash Framework3y ago
37 replies
rohan

Can't use `actor` on aggregates

Hi - I'm trying to use ^actor on aggregates but it's throwing an error.
This is my aggregate:
  aggregates do
    first :max_index, :audio_files, :index do
      sort index: :desc
      filter expr(user_id == ^actor(:id))
    end
  end


But calling: Practice.load!(visit, :max_index, actor: user, authorize?: true)

causes:
** (Ecto.SubQueryError) the following exception happened when compiling a subquery.

    ** (Ecto.Query.CastError) deps/ash_postgres/lib/expr.ex:530: value `{:_actor, :id}` in `where` cannot be cast to type #Ash.Type.UUID.EctoType<[]> in query:


Removing the ^actor works as expected though (but doesn't filter what I need to ofc)
Was this page helpful?