Ash FrameworkAF
Ash Framework8mo ago
69 replies
stephan8843

inline `type()` doesnt work. when defined as calculation on resource it works.

i have a really weird issue and i have no idea whats happening:

# this works, where `:id_as_string` is the calculation: expr(type(:id, :string))
authorize_if expr(^actor([:service, :id_as_string]) in addressed_groups)
   
# this doesnt work:
authorize_if expr(type(^actor([:service, :id]), :string) in addressed_groups)

addressed_groups is an {:array, :string} type. If I try to do the type casting inline, second example I get this error:

     Invalid Error

     * Invalid filter value `246` supplied in `#Ecto.Query<from w0 in ExEbau.Workflow.WorkItem, as: 0, where: not is_nil(
       type(
         as(0).deadline,
         {:parameterized,
          {Ash.Type.DateTime.EctoType,
           precision: :second, cast_dates_as: :start_of_day, timezone: :utc}}
       )
     ), where: type(^246, {:parameterized, {AshPostgres.Type.StringWrapper.EctoType, []}}) in type(
       as(0).addressed_groups,
       {:array, {:parameterized, {AshPostgres.Type.StringWrapper.EctoType, []}}}
     ), select: struct(w0, [
Was this page helpful?