OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
use AR`s upsert to avoid deactivating optimistic_locking
ulferts67750db3a7d7
diff --git a/app/models/application_record.rb b/app/models/application_record.rbindex 9f514ad0e77..9e8e75ac31f 100644--- a/app/models/application_record.rb+++ b/app/models/application_record.rb@@ -77,12 +77,4 @@ class ApplicationRecord < ActiveRecord::BaseActiveRecord::Base.connection.select_value(union_query)end-- def self.skip_optimistic_locking(&)- original_lock_optimistically = ActiveRecord::Base.lock_optimistically- ActiveRecord::Base.lock_optimistically = false- yield- ensure- ActiveRecord::Base.lock_optimistically = original_lock_optimistically- endenddiff --git a/modules/meeting/app/models/meeting.rb b/modules/meeting/app/models/meeting.rbindex 8afabfef1c6..62904a1c369 100644--- a/modules/meeting/app/models/meeting.rb+++ b/modules/meeting/app/models/meeting.rb@@ -250,28 +250,10 @@ class Meeting < ApplicationRecordtopend- # Disable optimistic locking in order to avoid causing `StaleObjectError`.- MeetingAgendaItem.skip_optimistic_locking do- MeetingAgendaItem.import(- changed_items,- on_duplicate_key_update: {- conflict_target: [:id],- columns: %i[meeting_id- author_id- title- notes- position- duration_in_minutes- start_time- end_time- created_at- updated_at- work_package_id- item_type- lock_version]- }- )- end+ MeetingAgendaItem.upsert_all(+ changed_items.map(&:attributes),+ unique_by: :id+ )endend