Ash FrameworkAF
Ash Framework8mo ago
7 replies
Georges

ash_sqlite: Error when querying on an inline code calculation

Hey there!

I'm trying out ash_sqlite on a toy project, and I'm encountering an issue which seems to boil down to querying a calculation defined as inline elixir code.

Here is the error (full stacktrace in the next post), followed by some relevant code. Happy to add more context if required.

* ** (UndefinedFunctionError) function Ash.Resource.Calculation.Function.expression/2 is undefined or private
  (ash 3.5.21) Ash.Resource.Calculation.Function.expression([fun: &BlueBox.Events.Event.calculation_0_generated_9B4035288DB6056F8A43EB5D284DE007/2], %Ash.Resource.Calculation.Context{actor: nil, tenant: nil, authorize?: true, tracer: nil, domain: nil, resource: nil, type: Ash.Type.String, constraints: [trim?: true, allow_empty?: false], arguments: %{}, source_context: %{private: %{authorize?: true, actor: nil}}})
  (ash_sql 0.2.80) lib/expr.ex:1457: AshSql.Expr.default_dynamic_expr/6
...


This is invoked as Event |> Ash.Query.filter(text_data == "asd") |> Ash.read, where text_data is defined as follow:

     calculate :text_data, :string, fn records, _context ->
      Enum.map(records, fn event ->
        inspect(event.data)
      end)
    end

(the point is to have quick-and-dirty full text search on the content of a json
data
payload).

Any guess on what could be happening here?
Solution
You can't filter on calculations that don't define an expression
Was this page helpful?