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
I’m aware of 2 such projects, are there others?
git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hi everyone.
My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
Hello folks!
So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
How Can I Optimise Compile Time Dependencies
I have been building an elixir application for about 2 years now. Many modules and files ha...
New
Other Trending Topics
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with.
But I don’t use it anymore.
Serverless was the promis...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #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