aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-09-15 00:41:56 +0100
committerJon Leighton <j@jonathanleighton.com>2012-09-15 00:41:56 +0100
commit60c88e64e26682a954f7c8cd6669d409ffffcc8b (patch)
tree212d854fb0230e9ca2490aa37f269b2fd06d5884 /activerecord/lib/active_record/connection_adapters/abstract
parent02f56554d68cddae02ccc4a8511cc5c64210d258 (diff)
downloadrails-60c88e64e26682a954f7c8cd6669d409ffffcc8b.tar.gz
rails-60c88e64e26682a954f7c8cd6669d409ffffcc8b.tar.bz2
rails-60c88e64e26682a954f7c8cd6669d409ffffcc8b.zip
Fix test
Accidentally checked in commented test code. Fail. >_<
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/transaction.rb32
1 files changed, 19 insertions, 13 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb b/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb
index 1d0b3eb612..2117eae5cb 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb
@@ -35,10 +35,8 @@ module ActiveRecord
end
class OpenTransaction < Transaction #:nodoc:
- attr_reader :parent, :records
- attr_accessor :joinable
-
- alias joinable? joinable
+ attr_reader :parent, :records
+ attr_writer :joinable
def initialize(connection, parent)
super connection
@@ -46,6 +44,18 @@ module ActiveRecord
@parent = parent
@records = []
@finishing = false
+ @joinable = true
+ end
+
+ # This state is necesarry so that we correctly handle stuff that might
+ # happen in a commit/rollback. But it's kinda distasteful. Maybe we can
+ # find a better way to structure it in the future.
+ def finishing?
+ @finishing
+ end
+
+ def joinable?
+ @joinable && !finishing?
end
def number
@@ -56,16 +66,12 @@ module ActiveRecord
end
end
- # Database adapters expect that #open_transactions will be decremented
- # before we've actually executed a COMMIT or ROLLBACK. This is kinda
- # annoying, but for now we use this @finishing flag to toggle what value
- # #number should return.
- def finishing?
- @finishing
- end
-
def begin
- SavepointTransaction.new(connection, self)
+ if finishing?
+ parent.begin
+ else
+ SavepointTransaction.new(connection, self)
+ end
end
def rollback