Revision 1298:4f746d8966dd lib/plugins/awesome_nested_set

View differences:

lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb
413 413

  
414 414
        # on creation, set automatically lft and rgt to the end of the tree
415 415
        def set_default_left_and_right
416
          highest_right_row = nested_set_scope(:order => "#{quoted_right_column_name} desc").find(:first, :limit => 1,:lock => true )
416
          highest_right_row = nested_set_scope(:order => "#{quoted_right_column_name} desc").limit(1).lock(true).first
417 417
          maxright = highest_right_row ? (highest_right_row[right_column_name] || 0) : 0
418 418
          # adds the new node to the right of all existing nodes
419 419
          self[left_column_name] = maxright + 1
......
443 443
          in_tenacious_transaction do
444 444
            reload_nested_set
445 445
            # select the rows in the model that extend past the deletion point and apply a lock
446
            self.class.base_class.find(:all,
447
              :select => "id",
448
              :conditions => ["#{quoted_left_column_name} >= ?", left],
449
              :lock => true
450
            )
446
            self.class.base_class.
447
              select("id").
448
              where("#{quoted_left_column_name} >= ?", left).
449
              lock(true).
450
              all
451 451

  
452 452
            if acts_as_nested_set_options[:dependent] == :destroy
453 453
              descendants.each do |model|

Also available in: Unified diff