Ash 3.0 - Ash.update/1 fails to validate updated_at | Data layer does not support the function error

Ash 3.0 - Ash.update/1 is throwing an exception at updated_at column. How do I fix it? I tried several methods without success.

%WithClauseError{term: {:not_atomic, "Failed to validate expression required!(now()): \"data layer does not support the function error(Ash.Error.Changes.Required, %{type: :attribute, resource: Kamaro.Stock.Category, field: :updated_at})\""}}

Here are my codes:

    def handle_event("validate", %{"form" => params}, socket) do
    form = AshPhoenix.Form.validate(socket.assigns.form, params)

    |> assign(:form, form)
    |> noreply()

 def handle_event("save", %{"form" => params}, socket) do
    case AshPhoenix.Form.submit(socket.assigns.form, params: params) do
      {:ok, item} ->
        |> put_flash(:info, "Item saved!")
        |> push_navigate(to: ~p"/")
        |> noreply()

      {:error, form} ->
        assign(socket, form: form)
        |> noreply()

So, this looks like potentially two issues. Do you have ”ash-functions” in your list of installed_extensions in your repo?

It looks like we’re missing some handling for cases when that is not true

Thanks @zachdaniel. This solved the issue.

Here is what I did to resolve the problem:

  1. I added ash-functions to the installed_extensions.
  2. I had to regenerate migrations and run them.

We should update the getting started guide to add ash-functions in the installed_extensions.

  def installed_extensions do
    ["uuid-ossp", "citext", "ash-functions"]
1 Like