Ash FrameworkAF
Ash Framework3y ago
13 replies
Blibs

builk_create upsert seems to be broken

I have the following create in my resource:

    create :create do
      description "Creates a new predefined school"

      primary? true

      accept [:name, :uid, :geography, :address, :city, :district, :state, :country, :type]

      upsert? true
      upsert_identity :unique_uid
      upsert_fields [:name, :geography, :address, :city, :district, :state, :country, :type]
    end


the upsert_identity comes from this identity:

identity :unique_uid, [:uid]


Just so you know, the :uid field is not a primary key.

If I try to insert a row with the same uid as one that already exists in the DB using the create funciton, it works as expected and I get the ON CONFLICT ("uid") in the SQL query.

Now, if I try to do the same, but with a bulk_create call, the resulti SQL query will contain ON CONFLICT ("id"), in other words, it uses
id
instead of uid which was set by the upsert_identity function.
Was this page helpful?