active_record_upsert icon indicating copy to clipboard operation
active_record_upsert copied to clipboard

Upsert for Rails 5 / Active Record 5

Results 27 active_record_upsert issues
Sort by recently updated
recently updated
newest added

``` DETAIL: Process 24328 waits for ShareLock on transaction 16779530; blocked by process 5888. Process 5888 waits for ShareLock on transaction 16779529; blocked by process 24328. HINT: See server log...

**Context**: The problem is basically https://stackoverflow.com/questions/34708509/how-to-use-returning-with-on-conflict-in-postgresql/37543015 **Problem**: If you have a conditional upsert, `record.upsert!({arel_condition: upsert_condition})`, and the condition returns no rows, then the `record` object will be empty. **My situation**:...

Perhaps a failing test is a better PR? This is also about: https://github.com/jesjos/active_record_upsert/issues/128 This at least seems like something plausibly mergeable. Though I think my style is a bit different...

Example where there is a uniqueness constraint on Children's names ``` parent = Parent.new parent.children.build(name: "Ken") parent.save! ``` When the parent saves, it will auto-save the child. How can I...

Rails version 6 When upserting, association counter caches do not get incremented. It looks like counter caches do not get incremented with normal callbacks: https://github.com/rails/rails/blob/v6.1.5/activerecord/lib/active_record/counter_cache.rb#L165 I fixed it by incrementing...

If the `upsert` operation is protected by an `arel_condition` which results in no records upserted, the model callbacks still fire producing errors. If no records are upserted, no callbacks should...

bug
help wanted

I am trying to create/ update a record with associated data and also with a specific field only for the the create operation. I am running into the following situation:...

Is it possible to return the number of inserted records (or updated ones) as a result of executing the upsert statement? For example, when the `INSERT` succeeds, it could set...

question

I would like to do something along the lines of `... ON CONFLICT DO UPDATE SET x = x + 1 ...` Is this currently possible some how? Many thanks

question

This PR allows one to pass an explicit Postgres constraint name to `upsert_keys`: ```ruby class MyClass < ActiveRecord::Base upsert_keys constraint: 'my_constraint' end ``` This generates SQL like ```SQL INSERT INTO...

enhancement