activerecord 4.2.3 → 4.2.4.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activerecord might be problematic. Click here for more details.

Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +68 -0
  3. data/lib/active_record/associations/association.rb +15 -3
  4. data/lib/active_record/associations/association_scope.rb +1 -0
  5. data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +7 -3
  6. data/lib/active_record/associations/collection_association.rb +1 -7
  7. data/lib/active_record/associations/has_many_association.rb +8 -1
  8. data/lib/active_record/associations/has_many_through_association.rb +5 -1
  9. data/lib/active_record/associations/preloader.rb +4 -4
  10. data/lib/active_record/associations/singular_association.rb +2 -8
  11. data/lib/active_record/associations/through_association.rb +0 -6
  12. data/lib/active_record/autosave_association.rb +1 -1
  13. data/lib/active_record/callbacks.rb +5 -5
  14. data/lib/active_record/connection_adapters/abstract/connection_pool.rb +2 -2
  15. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +4 -1
  16. data/lib/active_record/connection_adapters/mysql2_adapter.rb +1 -1
  17. data/lib/active_record/connection_adapters/postgresql/oid/array.rb +1 -1
  18. data/lib/active_record/core.rb +4 -4
  19. data/lib/active_record/gem_version.rb +2 -2
  20. data/lib/active_record/migration.rb +2 -1
  21. data/lib/active_record/model_schema.rb +1 -1
  22. data/lib/active_record/railtie.rb +1 -1
  23. data/lib/active_record/railties/databases.rake +9 -6
  24. data/lib/active_record/relation.rb +2 -1
  25. data/lib/active_record/relation/merger.rb +24 -1
  26. data/lib/active_record/relation/query_methods.rb +1 -1
  27. data/lib/active_record/scoping/default.rb +1 -0
  28. data/lib/active_record/transactions.rb +6 -2
  29. metadata +10 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83fff93be7d9724b5d9d13b45e638b174eabf199
4
- data.tar.gz: 6fe2c952c3f2a117b3c950b84b1da94501d346df
3
+ metadata.gz: 2fb652035938d5b27f851dc66801d366e00f18ad
4
+ data.tar.gz: 1a08b25b8641157a2bf2dc8e16648ce93d997a4f
5
5
  SHA512:
6
- metadata.gz: 01f6932da3c8e2e8ec11cd1b294462875e84938ed4c7f34fa6b237cdcda146490e1fa0b8b7d06b60aebfb964d0fb527810a364da7676699fd127b797bdb80c59
7
- data.tar.gz: 8052fcf30b1323df32dbcf697993052946ecfee89876edfbc5c619b8794ccf024f11f31aa22b137c0e25abc78dac8b629afd9690dbd6060e977df910b6a3bb61
6
+ metadata.gz: e0dafdbfbb59ab6a3a8c463575ab98db6f5a87dee9899ac6d99de9d4698d1992df32ff2068c61eedd6a9bb923564a051b1bf72c1e73449f8d0b706dd276ed6ab
7
+ data.tar.gz: 8cb2b713679f75a56f5ab6be12b72fe1acf675af600a58dd77f41ad03187aa11c4523edf464602ceb251e6d6ef6d8461365204d5086cca992d049e3b9411b568
@@ -1,3 +1,71 @@
1
+ ## Rails 4.2.4 (August 14, 2015) ##
2
+
3
+ * Skip statement cache on through association reader.
4
+
5
+ If the through class has default scopes we should skip the statement
6
+ cache.
7
+
8
+ Closes #20745.
9
+
10
+ *Rafael Mendonça França*
11
+
12
+ * Fixes #19420. When generating schema.rb using Postgres BigInt[] data type
13
+ the limit: 8 was not coming through. This caused it to become Int[] data type
14
+ after doing a rebuild off of schema.rb.
15
+
16
+ *Jake Waller*
17
+
18
+ * Fix state being carried over from previous transaction.
19
+
20
+ Considering the following example where `name` is a required attribute.
21
+ Before we had `new_record?` returning `true` for a persisted record:
22
+
23
+ author = Author.create! name: 'foo'
24
+ author.name = nil
25
+ author.save # => false
26
+ author.new_record? # => true
27
+
28
+ Fixes #20824.
29
+
30
+ *Roque Pinel*
31
+
32
+ * Correctly ignore `mark_for_destruction` when `autosave` isn't set to `true`
33
+ when validating associations.
34
+
35
+ Fixes #20882.
36
+
37
+ *Sean Griffin*
38
+
39
+ * Fix through associations using scopes having the scope merged multiple
40
+ times.
41
+
42
+ Fixes #20721.
43
+ Fixes #20727.
44
+
45
+ *Sean Griffin*
46
+
47
+ * `ActiveRecord::Base.dump_schema_after_migration` applies migration tasks
48
+ other than `db:migrate`. (eg. `db:rollback`, `db:migrate:dup`, ...)
49
+
50
+ Fixes #20743.
51
+
52
+ *Yves Senn*
53
+
54
+ * Correctly raise `ActiveRecord::AssociationTypeMismatch` when assigning
55
+ a wrong type to a namespaced association.
56
+
57
+ Fixes #20545.
58
+
59
+ *Diego Carrion*
60
+
61
+ * Prevent error when using `force_reload: true` on an unassigned polymorphic
62
+ belongs_to association.
63
+
64
+ Fixes #20426.
65
+
66
+ *James Dabbs*
67
+
68
+
1
69
  ## Rails 4.2.3 (June 25, 2015) ##
2
70
 
3
71
  * Let `WITH` queries (Common Table Expressions) be explainable.
@@ -211,9 +211,12 @@ module ActiveRecord
211
211
  # the kind of the class of the associated objects. Meant to be used as
212
212
  # a sanity check when you are about to assign an associated record.
213
213
  def raise_on_type_mismatch!(record)
214
- unless record.is_a?(reflection.klass) || record.is_a?(reflection.class_name.constantize)
215
- message = "#{reflection.class_name}(##{reflection.klass.object_id}) expected, got #{record.class}(##{record.class.object_id})"
216
- raise ActiveRecord::AssociationTypeMismatch, message
214
+ unless record.is_a?(reflection.klass)
215
+ fresh_class = reflection.class_name.safe_constantize
216
+ unless fresh_class && record.is_a?(fresh_class)
217
+ message = "#{reflection.class_name}(##{reflection.klass.object_id}) expected, got #{record.class}(##{record.class.object_id})"
218
+ raise ActiveRecord::AssociationTypeMismatch, message
219
+ end
217
220
  end
218
221
  end
219
222
 
@@ -248,6 +251,15 @@ module ActiveRecord
248
251
  initialize_attributes(record)
249
252
  end
250
253
  end
254
+
255
+ # Returns true if statement cache should be skipped on the association reader.
256
+ def skip_statement_cache?
257
+ reflection.scope_chain.any?(&:any?) ||
258
+ scope.eager_loading? ||
259
+ klass.current_scope ||
260
+ klass.default_scopes.any? ||
261
+ reflection.source_reflection.active_record.default_scopes.any?
262
+ end
251
263
  end
252
264
  end
253
265
  end
@@ -165,6 +165,7 @@ module ActiveRecord
165
165
  scope.where_values += item.where_values
166
166
  scope.bind_values += item.bind_values
167
167
  scope.order_values |= item.order_values
168
+ scope.unscope!(*item.unscope_values)
168
169
  end
169
170
  end
170
171
 
@@ -46,7 +46,7 @@ module ActiveRecord::Associations::Builder
46
46
 
47
47
  join_model = Class.new(ActiveRecord::Base) {
48
48
  class << self;
49
- attr_accessor :class_resolver
49
+ attr_accessor :left_model
50
50
  attr_accessor :name
51
51
  attr_accessor :table_name_resolver
52
52
  attr_accessor :left_reflection
@@ -58,7 +58,7 @@ module ActiveRecord::Associations::Builder
58
58
  end
59
59
 
60
60
  def self.compute_type(class_name)
61
- class_resolver.compute_type class_name
61
+ left_model.compute_type class_name
62
62
  end
63
63
 
64
64
  def self.add_left_association(name, options)
@@ -72,11 +72,15 @@ module ActiveRecord::Associations::Builder
72
72
  self.right_reflection = _reflect_on_association(rhs_name)
73
73
  end
74
74
 
75
+ def self.retrieve_connection
76
+ left_model.retrieve_connection
77
+ end
78
+
75
79
  }
76
80
 
77
81
  join_model.name = "HABTM_#{association_name.to_s.camelize}"
78
82
  join_model.table_name_resolver = habtm
79
- join_model.class_resolver = lhs_model
83
+ join_model.left_model = lhs_model
80
84
 
81
85
  join_model.add_left_association :left_side, anonymous_class: lhs_model
82
86
  join_model.add_right_association association_name, belongs_to_options(options)
@@ -431,13 +431,7 @@ module ActiveRecord
431
431
 
432
432
  private
433
433
  def get_records
434
- if reflection.scope_chain.any?(&:any?) ||
435
- scope.eager_loading? ||
436
- klass.current_scope ||
437
- klass.default_scopes.any?
438
-
439
- return scope.to_a
440
- end
434
+ return scope.to_a if skip_statement_cache?
441
435
 
442
436
  conn = klass.connection
443
437
  sc = reflection.association_scope_cache(conn, owner) do
@@ -80,8 +80,15 @@ module ActiveRecord
80
80
  [association_scope.limit_value, count].compact.min
81
81
  end
82
82
 
83
+
84
+ # Returns whether a counter cache should be used for this association.
85
+ #
86
+ # The counter_cache option must be given on either the owner or inverse
87
+ # association, and the column must be present on the owner.
83
88
  def has_cached_counter?(reflection = reflection())
84
- owner.attribute_present?(cached_counter_attribute_name(reflection))
89
+ if reflection.options[:counter_cache] || (inverse = inverse_which_updates_counter_cache(reflection)) && inverse.options[:counter_cache]
90
+ owner.attribute_present?(cached_counter_attribute_name(reflection))
91
+ end
85
92
  end
86
93
 
87
94
  def cached_counter_attribute_name(reflection = reflection())
@@ -162,7 +162,7 @@ module ActiveRecord
162
162
  count = scope.destroy_all.length
163
163
  else
164
164
  scope.each do |record|
165
- record.run_callbacks :destroy
165
+ record._run_destroy_callbacks
166
166
  end
167
167
 
168
168
  arel = scope.arel
@@ -229,6 +229,10 @@ module ActiveRecord
229
229
  false
230
230
  end
231
231
 
232
+ def has_cached_counter?(reflection = reflection())
233
+ owner.attribute_present?(cached_counter_attribute_name(reflection))
234
+ end
235
+
232
236
  def through_reflection_updates_counter_cache?
233
237
  counter_name = cached_counter_attribute_name
234
238
  inverse_updates_counter_named?(counter_name, through_reflection)
@@ -10,13 +10,13 @@ module ActiveRecord
10
10
  # end
11
11
  #
12
12
  # class Book < ActiveRecord::Base
13
- # # columns: title, sales
13
+ # # columns: title, sales, author_id
14
14
  # end
15
15
  #
16
16
  # When you load an author with all associated books Active Record will make
17
17
  # multiple queries like this:
18
18
  #
19
- # Author.includes(:books).where(:name => ['bell hooks', 'Homer').to_a
19
+ # Author.includes(:books).where(name: ['bell hooks', 'Homer']).to_a
20
20
  #
21
21
  # => SELECT `authors`.* FROM `authors` WHERE `name` IN ('bell hooks', 'Homer')
22
22
  # => SELECT `books`.* FROM `books` WHERE `author_id` IN (2, 5)
@@ -160,7 +160,7 @@ module ActiveRecord
160
160
  h
161
161
  end
162
162
 
163
- class AlreadyLoaded
163
+ class AlreadyLoaded # :nodoc:
164
164
  attr_reader :owners, :reflection
165
165
 
166
166
  def initialize(klass, owners, reflection, preload_scope)
@@ -175,7 +175,7 @@ module ActiveRecord
175
175
  end
176
176
  end
177
177
 
178
- class NullPreloader
178
+ class NullPreloader # :nodoc:
179
179
  def self.new(klass, owners, reflection, preload_scope); self; end
180
180
  def self.run(preloader); end
181
181
  def self.preloaded_records; []; end
@@ -3,7 +3,7 @@ module ActiveRecord
3
3
  class SingularAssociation < Association #:nodoc:
4
4
  # Implements the reader method, e.g. foo.bar for Foo.has_one :bar
5
5
  def reader(force_reload = false)
6
- if force_reload
6
+ if force_reload && klass
7
7
  klass.uncached { reload }
8
8
  elsif !loaded? || stale_target?
9
9
  reload
@@ -39,13 +39,7 @@ module ActiveRecord
39
39
  end
40
40
 
41
41
  def get_records
42
- if reflection.scope_chain.any?(&:any?) ||
43
- scope.eager_loading? ||
44
- klass.current_scope ||
45
- klass.default_scopes.any?
46
-
47
- return scope.limit(1).to_a
48
- end
42
+ return scope.limit(1).to_a if skip_statement_cache?
49
43
 
50
44
  conn = klass.connection
51
45
  sc = reflection.association_scope_cache(conn, owner) do
@@ -15,12 +15,6 @@ module ActiveRecord
15
15
  scope = super
16
16
  reflection.chain.drop(1).each do |reflection|
17
17
  relation = reflection.klass.all
18
-
19
- reflection_scope = reflection.scope
20
- if reflection_scope && reflection_scope.arity.zero?
21
- relation = relation.merge(reflection_scope)
22
- end
23
-
24
18
  scope.merge!(
25
19
  relation.except(:select, :create_with, :includes, :preload, :joins, :eager_load)
26
20
  )
@@ -318,7 +318,7 @@ module ActiveRecord
318
318
  # the parent, <tt>self</tt>, if it wasn't. Skips any <tt>:autosave</tt>
319
319
  # enabled records if they're marked_for_destruction? or destroyed.
320
320
  def association_valid?(reflection, record)
321
- return true if record.destroyed? || record.marked_for_destruction?
321
+ return true if record.destroyed? || (reflection.options[:autosave] && record.marked_for_destruction?)
322
322
 
323
323
  validation_context = self.validation_context unless [:create, :update].include?(self.validation_context)
324
324
  unless valid = record.valid?(validation_context)
@@ -289,25 +289,25 @@ module ActiveRecord
289
289
  end
290
290
 
291
291
  def destroy #:nodoc:
292
- run_callbacks(:destroy) { super }
292
+ _run_destroy_callbacks { super }
293
293
  end
294
294
 
295
295
  def touch(*) #:nodoc:
296
- run_callbacks(:touch) { super }
296
+ _run_touch_callbacks { super }
297
297
  end
298
298
 
299
299
  private
300
300
 
301
301
  def create_or_update #:nodoc:
302
- run_callbacks(:save) { super }
302
+ _run_save_callbacks { super }
303
303
  end
304
304
 
305
305
  def _create_record #:nodoc:
306
- run_callbacks(:create) { super }
306
+ _run_create_callbacks { super }
307
307
  end
308
308
 
309
309
  def _update_record(*) #:nodoc:
310
- run_callbacks(:update) { super }
310
+ _run_update_callbacks { super }
311
311
  end
312
312
  end
313
313
  end
@@ -361,7 +361,7 @@ module ActiveRecord
361
361
  synchronize do
362
362
  owner = conn.owner
363
363
 
364
- conn.run_callbacks :checkin do
364
+ conn._run_checkin_callbacks do
365
365
  conn.expire
366
366
  end
367
367
 
@@ -452,7 +452,7 @@ module ActiveRecord
452
452
  end
453
453
 
454
454
  def checkout_and_verify(c)
455
- c.run_callbacks :checkout do
455
+ c._run_checkout_callbacks do
456
456
  c.verify!
457
457
  end
458
458
  c
@@ -802,7 +802,10 @@ module ActiveRecord
802
802
  end
803
803
 
804
804
  def foreign_key_column_for(table_name) # :nodoc:
805
- "#{table_name.to_s.singularize}_id"
805
+ prefix = Base.table_name_prefix
806
+ suffix = Base.table_name_suffix
807
+ name = table_name.to_s =~ /#{prefix}(.+)#{suffix}/ ? $1 : table_name.to_s
808
+ "#{name.singularize}_id"
806
809
  end
807
810
 
808
811
  def dump_schema_information #:nodoc:
@@ -271,7 +271,7 @@ module ActiveRecord
271
271
  end
272
272
 
273
273
  def full_version
274
- @full_version ||= @connection.info[:version]
274
+ @full_version ||= @connection.server_info[:version]
275
275
  end
276
276
 
277
277
  def set_field_encoding field_name
@@ -18,7 +18,7 @@ module ActiveRecord
18
18
  end
19
19
 
20
20
  attr_reader :subtype, :delimiter
21
- delegate :type, to: :subtype
21
+ delegate :type, :limit, to: :subtype
22
22
 
23
23
  def initialize(subtype, delimiter = ',')
24
24
  @subtype = subtype
@@ -281,7 +281,7 @@ module ActiveRecord
281
281
  init_attributes(attributes, options) if attributes
282
282
 
283
283
  yield self if block_given?
284
- run_callbacks :initialize
284
+ _run_initialize_callbacks
285
285
  end
286
286
 
287
287
  # Initialize an empty model object from +coder+. +coder+ should be
@@ -307,8 +307,8 @@ module ActiveRecord
307
307
 
308
308
  self.class.define_attribute_methods
309
309
 
310
- run_callbacks :find
311
- run_callbacks :initialize
310
+ _run_find_callbacks
311
+ _run_initialize_callbacks
312
312
 
313
313
  self
314
314
  end
@@ -344,7 +344,7 @@ module ActiveRecord
344
344
  @attributes = @attributes.dup
345
345
  @attributes.reset(self.class.primary_key)
346
346
 
347
- run_callbacks(:initialize)
347
+ _run_initialize_callbacks
348
348
 
349
349
  @aggregation_cache = {}
350
350
  @association_cache = {}
@@ -7,8 +7,8 @@ module ActiveRecord
7
7
  module VERSION
8
8
  MAJOR = 4
9
9
  MINOR = 2
10
- TINY = 3
11
- PRE = nil
10
+ TINY = 4
11
+ PRE = "rc1"
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
@@ -652,7 +652,8 @@ module ActiveRecord
652
652
  unless @connection.respond_to? :revert
653
653
  unless arguments.empty? || [:execute, :enable_extension, :disable_extension].include?(method)
654
654
  arguments[0] = proper_table_name(arguments.first, table_name_options)
655
- if [:rename_table, :add_foreign_key].include?(method)
655
+ if [:rename_table, :add_foreign_key].include?(method) ||
656
+ (method == :remove_foreign_key && !arguments.second.is_a?(Hash))
656
657
  arguments[1] = proper_table_name(arguments.second, table_name_options)
657
658
  end
658
659
  end
@@ -295,7 +295,7 @@ module ActiveRecord
295
295
  def reset_column_information
296
296
  connection.clear_cache!
297
297
  undefine_attribute_methods
298
- connection.schema_cache.clear_table_cache!(table_name) if table_exists?
298
+ connection.schema_cache.clear_table_cache!(table_name)
299
299
 
300
300
  @arel_engine = nil
301
301
  @column_names = nil
@@ -147,8 +147,8 @@ end_warning
147
147
  ActiveSupport.on_load(:active_record) do
148
148
  ActionDispatch::Reloader.send(hook) do
149
149
  if ActiveRecord::Base.connected?
150
- ActiveRecord::Base.clear_reloadable_connections!
151
150
  ActiveRecord::Base.clear_cache!
151
+ ActiveRecord::Base.clear_reloadable_connections!
152
152
  end
153
153
  end
154
154
  end
@@ -42,15 +42,18 @@ db_namespace = namespace :db do
42
42
  desc "Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)."
43
43
  task :migrate => [:environment, :load_config] do
44
44
  ActiveRecord::Tasks::DatabaseTasks.migrate
45
- db_namespace['_dump'].invoke if ActiveRecord::Base.dump_schema_after_migration
45
+ db_namespace['_dump'].invoke
46
46
  end
47
47
 
48
+ # IMPORTANT: This task won't dump the schema if ActiveRecord::Base.dump_schema_after_migration is set to false
48
49
  task :_dump do
49
- case ActiveRecord::Base.schema_format
50
- when :ruby then db_namespace["schema:dump"].invoke
51
- when :sql then db_namespace["structure:dump"].invoke
52
- else
53
- raise "unknown schema format #{ActiveRecord::Base.schema_format}"
50
+ if ActiveRecord::Base.dump_schema_after_migration
51
+ case ActiveRecord::Base.schema_format
52
+ when :ruby then db_namespace["schema:dump"].invoke
53
+ when :sql then db_namespace["structure:dump"].invoke
54
+ else
55
+ raise "unknown schema format #{ActiveRecord::Base.schema_format}"
56
+ end
54
57
  end
55
58
  # Allow this task to be called as many times as required. An example is the
56
59
  # migrate:redo task, which calls other two internally that depend on this one.
@@ -474,7 +474,8 @@ module ActiveRecord
474
474
  stmt.wheres = arel.constraints
475
475
  end
476
476
 
477
- affected = @klass.connection.delete(stmt, 'SQL', bind_values)
477
+ bvs = arel.bind_values + bind_values
478
+ affected = @klass.connection.delete(stmt, 'SQL', bvs)
478
479
 
479
480
  reset
480
481
  affected
@@ -51,7 +51,8 @@ module ActiveRecord
51
51
 
52
52
  NORMAL_VALUES = Relation::SINGLE_VALUE_METHODS +
53
53
  Relation::MULTI_VALUE_METHODS -
54
- [:joins, :where, :order, :bind, :reverse_order, :lock, :create_with, :reordering, :from] # :nodoc:
54
+ [:includes, :preload, :joins, :where, :order, :bind, :reverse_order, :lock, :create_with, :reordering, :from] # :nodoc:
55
+
55
56
 
56
57
  def normal_values
57
58
  NORMAL_VALUES
@@ -75,6 +76,7 @@ module ActiveRecord
75
76
 
76
77
  merge_multi_values
77
78
  merge_single_values
79
+ merge_preloads
78
80
  merge_joins
79
81
 
80
82
  relation
@@ -82,6 +84,27 @@ module ActiveRecord
82
84
 
83
85
  private
84
86
 
87
+ def merge_preloads
88
+ return if other.preload_values.empty? && other.includes_values.empty?
89
+
90
+ if other.klass == relation.klass
91
+ relation.preload!(*other.preload_values) unless other.preload_values.empty?
92
+ relation.includes!(other.includes_values) unless other.includes_values.empty?
93
+ else
94
+ reflection = relation.klass.reflect_on_all_associations.find do |r|
95
+ r.class_name == other.klass.name
96
+ end || return
97
+
98
+ unless other.preload_values.empty?
99
+ relation.preload! reflection.name => other.preload_values
100
+ end
101
+
102
+ unless other.includes_values.empty?
103
+ relation.includes! reflection.name => other.includes_values
104
+ end
105
+ end
106
+ end
107
+
85
108
  def merge_joins
86
109
  return if other.joins_values.blank?
87
110
 
@@ -907,7 +907,7 @@ module ActiveRecord
907
907
  def where_unscoping(target_value)
908
908
  target_value = target_value.to_s
909
909
 
910
- where_values.reject! do |rel|
910
+ self.where_values = where_values.reject do |rel|
911
911
  case rel
912
912
  when Arel::Nodes::Between, Arel::Nodes::In, Arel::Nodes::NotIn, Arel::Nodes::Equality, Arel::Nodes::NotEqual, Arel::Nodes::LessThan, Arel::Nodes::LessThanOrEqual, Arel::Nodes::GreaterThan, Arel::Nodes::GreaterThanOrEqual
913
913
  subrelation = (rel.left.kind_of?(Arel::Attributes::Attribute) ? rel.left : rel.right)
@@ -95,6 +95,7 @@ module ActiveRecord
95
95
  end
96
96
 
97
97
  def build_default_scope(base_rel = relation) # :nodoc:
98
+ return if abstract_class?
98
99
  if !Base.is_a?(method(:default_scope).owner)
99
100
  # The user has defined their own default scope method, so call that
100
101
  evaluate_default_scope { default_scope }
@@ -311,7 +311,7 @@ module ActiveRecord
311
311
  # Ensure that it is not called if the object was never persisted (failed create),
312
312
  # but call it after the commit of a destroyed object.
313
313
  def committed!(should_run_callbacks = true) #:nodoc:
314
- run_callbacks(:commit) if should_run_callbacks && destroyed? || persisted?
314
+ _run_commit_callbacks if should_run_callbacks && destroyed? || persisted?
315
315
  ensure
316
316
  force_clear_transaction_record_state
317
317
  end
@@ -319,7 +319,7 @@ module ActiveRecord
319
319
  # Call the +after_rollback+ callbacks. The +force_restore_state+ argument indicates if the record
320
320
  # state should be rolled back to the beginning or just to the last savepoint.
321
321
  def rolledback!(force_restore_state = false, should_run_callbacks = true) #:nodoc:
322
- run_callbacks(:rollback) if should_run_callbacks
322
+ _run_rollback_callbacks if should_run_callbacks
323
323
  ensure
324
324
  restore_transaction_record_state(force_restore_state)
325
325
  clear_transaction_record_state
@@ -357,6 +357,10 @@ module ActiveRecord
357
357
  raise ActiveRecord::Rollback unless status
358
358
  end
359
359
  status
360
+ ensure
361
+ if @transaction_state && @transaction_state.committed?
362
+ clear_transaction_record_state
363
+ end
360
364
  end
361
365
 
362
366
  protected
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.3
4
+ version: 4.2.4.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-25 00:00:00.000000000 Z
11
+ date: 2015-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.3
19
+ version: 4.2.4.rc1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 4.2.3
26
+ version: 4.2.4.rc1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activemodel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 4.2.3
33
+ version: 4.2.4.rc1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 4.2.3
40
+ version: 4.2.4.rc1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: arel
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -298,13 +298,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
298
298
  version: 1.9.3
299
299
  required_rubygems_version: !ruby/object:Gem::Requirement
300
300
  requirements:
301
- - - ">="
301
+ - - ">"
302
302
  - !ruby/object:Gem::Version
303
- version: '0'
303
+ version: 1.3.1
304
304
  requirements: []
305
305
  rubyforge_project:
306
- rubygems_version: 2.4.5
306
+ rubygems_version: 2.4.7
307
307
  signing_key:
308
308
  specification_version: 4
309
309
  summary: Object-relational mapper framework (part of Rails).
310
310
  test_files: []
311
+ has_rdoc: