This project is archived and is in readonly mode.
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
-
Carlos Forero July 26th, 2010 @ 08:03 PM
I'm sorry. The problem was the following code that another developer had added:
class ApplicationController < ActionController::Base prepend_around_filter :action_transaction def action_transaction ActiveRecord::Base.transaction do yield end end end
thanks anyway
-
Neeraj Singh July 26th, 2010 @ 08:24 PM
- State changed from new to invalid
- Importance changed from to Low
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>