dongwooklee96

dongwooklee96

Hi I would like to do a bulk_description as shown in the example bulk_destory as shown in the example.

However, I ran into the error below.

[error] 6efcbea5-5a0e-403c-9731-b17a2dccfbcc: Exception raised while resolving query.

** (UndefinedFunctionError) function Ash.bulk_destroy!/2 is undefined or private

Can you tell me what the problem is?

actions do

defaults [:read, :destroy]
...
action :bulk_destroy_user_noti, :boolean do
      argument :ids, {:array, :uuid}, allow_nil?: false

      run fn input, context ->
        IO.inspect(input.arguments.ids)

        __MODULE__
        |> Ash.Query.filter(id in ^input.arguments.ids)
        |> Ash.bulk_destroy!(:destroy)
        |> dbg

        {:ok, false}
      end
    end
end

Showing Posts 1 to 10

03juan

03juan

The function in the documentation is bulk_destroy!/4 so it’s expecting up to 4 arguments and the last one is optional:

bulk_destroy!(stream_or_query, action, input, opts \\ [])

I think the documentation link in your post has a bug and it should be passing a 3rd parameter

Ticket
|> Ash.Query.filter(status == :open)
|> Ash.bulk_destroy!(:close, %{}) 

because the next example is

Ash.bulk_destroy!(one_hundred_tickets, :close, %{}, batch_size: 10)

Please try to change your code to

__MODULE__
        |> Ash.Query.filter(id in ^input.arguments.ids)
        |> Ash.bulk_destroy!(:destroy, %{})
zachdaniel

zachdaniel

Creator of Ash

Yes, this is correct. An empty input is required even if the action takes no inputs.

dongwooklee96

dongwooklee96 OP

action :bulk_destroy_user_notification, :boolean do

      argument :ids, {:array, :uuid}, allow_nil?: false

      run fn input, context ->
        ids = input.arguments.ids

        __MODULE__
        |> Ash.Query.filter(id in ^ids)
        |> Ash.bulk_destroy(:destroy, %{}, return_errors?: true)
        |> dbg

        {:ok, true}
      end
    end

Sorry for the late reply

Ash.bulk_destroy(:destroy, %{}, return_errors?: true, strategy: :atomic) #=> %Ash.BulkResult{
  status: :error,
  errors: [
    %Ash.Error.Invalid{
      errors: [
        %Ash.Error.Invalid.NoMatchingBulkStrategy{
          resource: Dentallog.Accounts.UserNotification,
          action: :destroy,
          requested_strategies: [:atomic],
          not_stream_reason: nil,
          not_atomic_batches_reason: "Not in requested strategies",
          not_atomic_reason: "AshArchival.Resource.Changes.ArchiveRelated does not implement `atomic/3`",
          footer: nil,
          splode: Ash.Error,
          bread_crumbs: [],
          vars: [],
          path: [],
          stacktrace: #Splode.Stacktrace<>,
          class: :invalid
        }
      ]
    }
  ],
  records: nil,
  notifications: nil,
  error_count: 1
}

The bulk_destory itself succeeded, but the

not_atomic_batches_reason: "Not in requested strategies",
          not_atomic_reason: "AshArchival.Resource.Changes.ArchiveRelated does not implement `atomic/3`",

I am getting the above error. It seems to be related to AshArchival.

zachdaniel

zachdaniel

Creator of Ash

I believe we updated AshArchival to support bulk atomic updates, but there were also some unreleased changes. Please upgrade ash_archival and give it a try.

dongwooklee96

dongwooklee96 OP

{:ash, "~> 3.0.16"},
{:ash_postgres, "~> 2.0.12"},
{:ash_phoenix, "~> 2.0.4"},
{:ash_archival, git: "https://github.com/ash-project/ash_archival.git"},
{:ash_paper_trail, git: "https://github.com/ash-project/ash_paper_trail.git"},
{:ash_graphql, "~> 1.2.0"},
{:ash_authentication, "~> 4.0.1"},
{:ash_authentication_phoenix, "~> 2.0.0"},

I’m using that version, but is there a more recent version than this?

zachdaniel

zachdaniel

Creator of Ash

That doesn’t show me what version of ash_archival you are using. You’re pointing at “some commit”, but which commit is not specified. Do mix deps.update ash_archival (also, I’d suggest not using GitHub dependencies unless absolutely necessary, or for testing things)

dongwooklee96

dongwooklee96 OP

I thought it was automatically reading the latest source, sorry.

defp deps do
    [
      {:ash, "~> 3.0.16"},
      {:ash_postgres, "~> 2.0.12"},
      {:ash_phoenix, "~> 2.0.4"},
      {:ash_archival, "~> 1.0.1"},
      {:ash_paper_trail, "~> 0.1.2"},
      {:ash_graphql, "~> 1.2.0"},
      {:ash_authentication, "~> 4.0.1"},
      {:ash_authentication_phoenix, "~> 2.0.0"},
      {:phoenix, "~> 1.7.12"},
      {:phoenix_ecto, "~> 4.5.1"},
      {:ecto_sql, "~> 3.11.1"},
      {:postgrex, ">= 0.17.5"},
      {:phoenix_html, "~> 4.0"},
      {:phoenix_live_reload, "~> 1.2", only: :dev},
      {:phoenix_live_view, "~> 0.20.1"},
      {:floki, ">= 0.30.0", only: :test},
      {:phoenix_live_dashboard, "~> 0.8.2"},
      {:esbuild, "~> 0.8", runtime: Mix.env() == :dev},
      {:tailwind, "~> 0.2.0", runtime: Mix.env() == :dev},
      {:swoosh, "~> 1.15.3"},
      {:finch, "~> 0.13"},
      {:telemetry_metrics, "~> 0.6"},
      {:telemetry_poller, "~> 1.0"},
      {:gettext, "~> 0.20"},
      {:jason, "~> 1.2"},
      {:dns_cluster, "~> 0.1.1"},
      {:plug_cowboy, "~> 2.5"},
      {:guardian, "~> 2.3"},
      {:guardian_db, "~> 3.0"},
      {:absinthe, "~> 1.7"},
      {:picosat_elixir, "~> 0.2"},
      {:appsignal, "~> 2.0"}
    ]
  end

I used that dependency.

|> Ash.bulk_destroy(:destroy, %{}, return_errors?: true) #=> %Ash.BulkResult{
  status: :error,
  errors: [
    %Ash.Error.Invalid{
      errors: [
        %Ash.Error.Invalid.NoMatchingBulkStrategy{
          resource: Dentallog.Accounts.UserNotification,
          action: :destroy,
          requested_strategies: [:atomic_batches, :atomic],
          not_stream_reason: nil,
          not_atomic_batches_reason: "AshPaperTrail.Resource.Changes.CreateNewVersion does not implement `atomic/3`",
          not_atomic_reason: nil,
          footer: nil,
          splode: Ash.Error,
          bread_crumbs: [],
          vars: [],
          path: [],
          stacktrace: #Splode.Stacktrace<>,
          class: :invalid
        }
      ]
    }
  ],
  records: nil,
  notifications: nil,
  error_count: 1
}

But I still facing that error.

zachdaniel

zachdaniel

Creator of Ash

Okay, you will need to be on main of ash and ash_paper_trail for this to work, but I’ve pushed an atomic/3 callback there. I was wrong, we hadn’t added it before.

zachdaniel

zachdaniel

Creator of Ash

It isn’t optimized for batches though so would you mind opening an issue on ash_paper_trail requesting to optimize the atomic/3 behaviour for batches using after_batch/3?

dongwooklee96

dongwooklee96 OP

넵 알겠습니다. 이슈로 등록하였습니다.

https://github.com/ash-project/ash_paper_trail/issues/87

항상 그렇지만 많은 도움을 주셔서 감사합니다.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews