I’m having an issue with Ash.Geometry where I’m unable to update just the location. Here’s my code for reference:
New type to Geometry
defmodule JoinsApi.Types.Point4326 do
use AshGeo.Geometry,
storage_type: :"geometry(Point,4326)",
geo_types: :point
end
Resource
update :update_location do
argument :location, :geo_any do
allow_nil? false
constraints geo_types: :point
end
require_atomic? false
change set_attribute(:location, arg(:location))
end
Config Json Api Domain
json_api do
routes do
base_route "/profiles", JoinsApi.Accounts.Profile do
get :read
index :read
post :create
patch :update
delete :destroy
patch :update_location, route: "/:id/update_location"
end
base_route "/blocks", JoinsApi.Accounts.Block do
get :read
index :read
post :create
delete :destroy
end
end
end
Even put required_automic? false, still show error:
{
"errors": [
{
"code": "invalid",
"id": "1dc2e6c6-2ec1-4ae4-ae7c-1caf7b3f78d8",
"meta": {},
"status": "400",
"title": "Invalid",
"detail": "Cannot atomically update JoinsApi.Accounts.Profile.location: Type `JoinsApi.Types.Point4326` does not support atomic updates"
}
],
"jsonapi": {
"version": "1.0"
}
}
I’m fairly new to using Ash, and I’m trying to update the location attribute. However, I’m not sure why, when I pass the path to the route, I receive the following error:
Even use a accept
update :update_location do
accept [:location]
argument :location, :geo_any do
allow_nil? false
constraints geo_types: :point
end
require_atomic? false
change set_attribute(:location, arg(:location))
end
What version of ash and ash_postgres are you on? You’ll want to see what your locked version is not the version in your mix.exs is. You can run mix hex.info ash and mix hex.info ash_postgres to see your locked versions.
If you haven’t, its a good idea to update to the latest version to see if we’ve already fixed your issue.
Thank you for the reproduction This should be fixed in the latest main branch of Ash, and will be in the next release.
You can try it out with {:ash, github: "ash-project/ash"}. Additionally, I’ve made a PR to ash_geo (not my project) to address the fact that the type does not support atomic updates.