drikanius
Unknown Error (OriginalDataNotAvailable) when trying to create a update
Hi guys.
I have this module, and I’m just trying to create an update:
defmodule Marketplace.Ap.Appointment do
@moduledoc false
alias Marketplace.Ap
use Ash.Resource,
data_layer: AshPostgres.DataLayer
code_interface do
define_for Marketplace.Ap
define :create
define :update
define :get_by_lead
end
attributes do
uuid_primary_key :id
attribute :appt_type, :integer do
description "In-Home = 1, Virtual = 2"
end
attribute :appointment_time, :utc_datetime_usec
attribute :status, :string
attribute :name_assigned_to, :string
attribute :reschedule_uri, :string
attribute :cancel_uri, :string
attribute :cancel_reason, :string
attribute :cancel_notes, :string
attribute :cancel_by_type, :string
attribute :score, :integer, allow_nil?: false
timestamps()
end
relationships do
belongs_to :canceled_by, Ap.User
belongs_to :assigned_to, Ap.User
belongs_to :assigned_by, Ap.User do
primary_key? true
allow_nil? false
attribute_writable? true
end
belongs_to :lead, Ap.Lead do
attribute_writable? true
end
end
identities do
identity :unique_id, [:lead_id]
end
postgres do
table "appointment"
schema "dbo"
repo Marketplace.ApRepo
end
actions do
alias Marketplace.Ap.Actions.Appointment.Actions.Create
defaults [:read, :update]
create :create do
primary? true
accept [:score]
upsert? true
upsert_fields [:score, :updated_at, :appt_type]
upsert_identity :unique_id
argument :lead_id, :uuid, allow_nil?: false
argument :appt_type, :atom, allow_nil?: false
change Create.Changes.FixApptType
change set_attribute(:assigned_by_id, actor(:id))
change set_attribute(:lead_id, arg(:lead_id))
end
read :get_by_lead do
description "get appointment based on lead"
argument :lead_id, :uuid, allow_nil?: false
get? true
filter expr(lead_id == ^arg(:lead_id))
end
end
end
However, when I try to access using iex:
[appt] = Marketplace.Ap.Appointment |> Marketplace.Ap.read!
Marketplace.Ap.Appointment.update(appt, %{cancel_notes: "hi"})
I end up with this error:
** (Ash.Error.Unknown) Unknown Error
* ** (KeyError) key :__meta__ not found in: %Ash.Changeset.OriginalDataNotAvailable{reason: :atomic_query_update}
:erlang.map_get(:__meta__, %Ash.Changeset.OriginalDataNotAvailable{reason: :atomic_query_update})
(elixir 1.16.0) lib/map.ex:318: Map.update!/3
(ash_postgres 1.4.0) lib/data_layer.ex:1257: AshPostgres.DataLayer.update_query/4
(ash 2.18.1) lib/ash/actions/update/bulk.ex:278: Ash.Actions.Update.Bulk.do_atomic_update/4
(ash 2.18.1) lib/ash/actions/update/bulk.ex:120: Ash.Actions.Update.Bulk.run/5
(ash 2.18.1) lib/ash/actions/update/update.ex:81: Ash.Actions.Update.run/4
(marketplace 1.19.0) lib/marketplace/ap.ex:1: Marketplace.Ap.update/2
(stdlib 5.0.2) erl_eval.erl:746: :erl_eval.do_apply/7
(elixir 1.16.0) src/elixir.erl:378: :elixir.eval_forms/4
(elixir 1.16.0) lib/module/parallel_checker.ex:112: Module.ParallelChecker.verify/1
(iex 1.16.0) lib/iex/evaluator.ex:331: IEx.Evaluator.eval_and_inspect/3
(iex 1.16.0) lib/iex/evaluator.ex:305: IEx.Evaluator.eval_and_inspect_parsed/3
(iex 1.16.0) lib/iex/evaluator.ex:294: IEx.Evaluator.parse_eval_inspect/4
(iex 1.16.0) lib/iex/evaluator.ex:187: IEx.Evaluator.loop/1
(iex 1.16.0) lib/iex/evaluator.ex:32: IEx.Evaluator.init/5
(stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
:erlang.map_get(:__meta__, %Ash.Changeset.OriginalDataNotAvailable{reason: :atomic_query_update})
(elixir 1.16.0) lib/map.ex:318: Map.update!/3
(ash_postgres 1.4.0) lib/data_layer.ex:1257: AshPostgres.DataLayer.update_query/4
(ash 2.18.1) lib/ash/actions/update/bulk.ex:278: Ash.Actions.Update.Bulk.do_atomic_update/4
(ash 2.18.1) lib/ash/actions/update/bulk.ex:120: Ash.Actions.Update.Bulk.run/5
(ash 2.18.1) lib/ash/actions/update/update.ex:81: Ash.Actions.Update.run/4
(marketplace 1.19.0) lib/marketplace/ap.ex:1: Marketplace.Ap.update/2
Would anyone have any ideas on how to fix this?
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated!
To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead.
Sta...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New
Other Trending Topics
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance










First 10 of 23 Posts
zachdaniel
hello! I’m assuming you’re using
ashfrommainin that case. Can you also updateash_postgresto be frommainas well?drikanius
Actually I’m using both
ashandash_postgresfrommaindrikanius
I did some tests, and ended up realizing that all my updates for all resources are no longer working =/
They have different erros:
zachdaniel
Please try
mix deps.update ash ash_postgresdrikanius
After use
mix deps.update ash ash_postgresmy initial problem was solved. However I have other updates that give me those errors:I tried change to
{:ash, "~> 2.18", override: true}and{:ash_postgres, "~> 1.4"}.In this version update works fine. on master they dont.
If you prefer I can create a new topic
drikanius
First error I got it:
It seems that on master we must use
use Ash.Resource.Validation(before it worked without it, but it makes sense to be mandatory).But still have the second one
zachdaniel
Correct,
use Ash.Resource.Validationwill be necessary.I’m not familiar w/ that specific error, can you paste the full stacktrace/error message?
drikanius
This one?
Once again, on
{:ash, "~> 2.18", override: true}and{:ash_postgres, "~> 1.4"}, was working, now I got errorzachdaniel
Okay, try
ash_postgresmainagain please.mix deps.update ash_postgres. Lots of people work againstmainbranches, but just keep in mind that we’re gearing up for the 3.0 release, and are making some relatively significant changes inmain. Its starting to stabilize, just want to make sure you’re aware.drikanius
Still having the same error
Cool. I just added the version so you have the reference