This project is archived and is in readonly mode.

#5187 ✓invalid
Carlos Forero

fail rollback transaction with manual raise exception

Reported by Carlos Forero | July 23rd, 2010 @ 04:51 PM

With :
PostgreSQL 8.4 or postgresql-8.3 rails 2.3.4 pg 9.x or pg 8.x

I test this code:

class NkiBatch < ActiveRecord::Base
   def create_batches
     Bank.connection.transaction do

       bank = Bank.new(:name => "ddsjdsjdsjk")
       bank.save!
       raise ActiveRecord::Rollback.new
     end
   end
end

and this:

class NkiBatch < ActiveRecord::Base
   def create_batches
     Bank.connection.transaction do

       bank = Bank.new(:name => "ddsjdsjdsjk")
       bank.save!
       raise Exception.new
     end
  end
end

and this:

class NkiBatch < ActiveRecord::Base
   def self.create_batches
     Bank.connection.transaction do

       bank = Bank.new(:name => "ddsjdsjdsjk")
       bank.save!
       raise "Please, rollback"
     end
   end
end

but the record bank is saved succesfully into database

(I reported the problem in the community of pg driver, but they demonstrated that the problem is not the pg driver
http://bitbucket.org/ged/ruby-pg/issue/37/fail-rollback-transaction...)

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages