lib/sequel/plugins/upsert.rb in pact_broker-2.83.0 vs lib/sequel/plugins/upsert.rb in pact_broker-2.84.0
- old
+ new
@@ -26,10 +26,11 @@
end
load_values_from_previously_inserted_object unless id
self
rescue Sequel::NoExistingObject
load_values_from_previously_inserted_object
+ self
ensure
@upsert_plugin_upserting = false
end
private
@@ -43,9 +44,12 @@
if !primary_key_columns_are_same_as_identifying_columns
existing_record = find_previously_inserted_object
upsert_primary_key_columns.each do | column |
self.send("#{column}=".to_sym, existing_record[column])
end
+ # Need to clear out the _update_dataset when the NoExistingObject is thrown because
+ # the ID gets incremented somewhere in the Sequel code
+ @this = nil
end
end
def find_previously_inserted_object
query = self.class.upsert_plugin_identifying_columns.each_with_object({}) do | column_name, q |