drikanius
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
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
New
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
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
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
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
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