Type error from ash_postgres for `{:array, :map}`

I have this resource attribute:
actions do
defaults [:read, create: :*, update: :*]
end

attributes do
attribute :things, {:array, :map} do
default []
public? true
allow_nil? false
end
end
actions do
defaults [:read, create: :*, update: :*]
end

attributes do
attribute :things, {:array, :map} do
default []
public? true
allow_nil? false
end
end
When attempting to update the resource with resource |> Ash.Changeset.for_update(:update, %{things: [%{key: "value"}]}) |> Ash.update! I get this error:
Unknown Error

* ** (Postgrex.Error) ERROR 42804 (datatype_mismatch) column "things" is of type jsonb[] but expression is of type text[]
Unknown Error

* ** (Postgrex.Error) ERROR 42804 (datatype_mismatch) column "things" is of type jsonb[] but expression is of type text[]
I found this article https://elixirforum.com/t/ash-resource-update-error-postgrex-error-error-42804-datatype-mismatch-column-roles-is-of-type-jsonb/62136, but I'm on latest ash_postgres 2.6.17. Any insight into why I'm getting this would be great. It works fine when using an Ecto Schema and Changeset.
4 Replies
ZachDaniel
ZachDaniel4w ago
Are you on latest ash_sql too? Probably are but worth checking
bhelms
bhelmsOP4w ago
Yes, 0.2.92
ZachDaniel
ZachDaniel4w ago
Gotcha. Please put together a reproduction, either as its own app or a test in ash_postgres and I will investigate when I have time Until then, you can try setting require_atomic? false on the update action
bhelms
bhelmsOP4w ago
Ok. Thanks.

Did you find this page helpful?