Sorry for not putting the whole situation inside Zach!
Thank you for taking your time! 
So, I tried different strategies (putting upsert in actions vs putting in the for_change Changeset function etc), but couldn’t get it.
This is the latest example where I am defaulting I presume to :update_all, but Ecto is complaining that set() is empty, which shouldn’t be as I am passing arguments to it?
Is there an Ash way specifically to force the Ecto.set?
I presumed that all arguments are passed automatically?
(In the given example I already have data in the table that have the same Warehouse_CODE, (using identity for uniqueness and to force upsert)
Here is the Changeset :
Enum.map(Enum.zip(params["warehouse"]["code"], params["warehouse"]["type"]), fn pos ->
Warehouse
|> Ash.Changeset.new()
|> Ash.Changeset.for_create(
:create,
%{warehouse_code: elem(pos, 0), warehouse_name: "Heho", warehouse_type: elem(pos, 1)},
upsert?: true,
upsert_identity: :unique_record,
upsert_fields: [:replace_all])
|> Ash.Changeset.set_tenant("org_#{company.id}")
|> MetacrisisBi.Warehouse.create!()
end)
IO.inspect(new_warehouse)
Warehouse
|> Ash.Changeset.for_create(:create, new_warehouse)
|> Ash.Changeset.set_tenant("org_#{company.id}")
|> MetacrisisBi.Warehouse.create!()
Then from Warehouse resource:
attributes do
# Add an autogenerated UUID primary key called `:id`.
uuid_primary_key(:id)
attribute(:warehouse_name, :string)
attribute(:warehouse_code, :string)
attribute(:warehouse_type, :string)
end
identities do
identity(:unique_record, [:warehouse_code])
end
code_interface do
define_for(MetacrisisBi.Warehouse)
define(:create, args: [:warehouse_name, :warehouse_code, :warehouse_type], action: :create)
define(:read, action: :read)
define(:update, action: :update)
define(:destroy, action: :destroy)
end
in actions:
create :create do
primary? true
upsert? true
upsert_identity(:unique_record)
end
The error I get is:
[error] GenServer #PID<0.647.0> terminating
** (Ash.Error.Unknown) Unknown Error
* ** (Ecto.QueryError) `update_all` requires at least one field to be updated in query:
from r0 in MetacrisisBi.Warehouse.Record,
update: [set: []]
(ash 2.15.7) lib/ash/api/api.ex:2183: Ash.Api.unwrap_or_raise!/3
(elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2
(metacrisis_bi 0.1.0) lib/metacrisis_bi_web/warehouse/warehouse.ex:140: MetacrisisBiWeb.WarehouseLive.handle_event/3