Mohammed Morsi
2009-Oct-14 00:20 UTC
[Ovirt-devel] [PATCH server] hack betternested set to enable pool deletion
This is an ugly hack to fix the betternestedset plugin as currently a bug does not allow pools to be deleted. The single line commented out in this patch deletes the pool itself instead of only its children for whatever reason. This wouldn't be a problem were it not for the recent change to active record which enforces optimistic locking upon destroy operations. Since the database record is mistakingly deleted in betternestedset, via the 'before_destroy' hook, the record does not exist when the activerecord destroy operation is actually performed and thus an exception is thrown at /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/locking/optimistic.rb line 100 Note this patch only works since we explicitly disable a hw pool from being deleted unless all its children are in the oVirt hardware_pool_server. It is ugly but works until something more elegant can be found. --- .../betternestedset/lib/better_nested_set.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/vendor/plugins/betternestedset/lib/better_nested_set.rb b/src/vendor/plugins/betternestedset/lib/better_nested_set.rb index 9efbf25..ea8aea3 100644 --- a/src/vendor/plugins/betternestedset/lib/better_nested_set.rb +++ b/src/vendor/plugins/betternestedset/lib/better_nested_set.rb @@ -430,7 +430,7 @@ module SymetrieCom return unless reloaded dif = self[right_col_name] - self[left_col_name] + 1 if acts_as_nested_set_options[:dependent] == :delete_all - base_set_class.delete_all( "#{scope_condition} AND (#{prefixed_left_col_name} BETWEEN #{self[left_col_name]} AND #{self[right_col_name]})" ) + #base_set_class.delete_all( "#{scope_condition} AND (#{prefixed_left_col_name} BETWEEN #{self[left_col_name]} AND #{self[right_col_name]})" ) else set = base_set_class.find(:all, :conditions => "#{scope_condition} AND (#{prefixed_left_col_name} BETWEEN #{self[left_col_name]} AND #{self[right_col_name]})", :order => "#{prefixed_right_col_name} DESC") set.each { |child| child.skip_before_destroy = true; remove_descendant(child) } -- 1.6.0.6