activerecord 4.2.0.beta3 → 4.2.0.beta4

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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +35 -2
  3. data/lib/active_record/associations.rb +6 -0
  4. data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +1 -1
  5. data/lib/active_record/associations/collection_association.rb +6 -1
  6. data/lib/active_record/associations/collection_proxy.rb +14 -17
  7. data/lib/active_record/associations/has_many_through_association.rb +9 -6
  8. data/lib/active_record/associations/join_dependency.rb +12 -3
  9. data/lib/active_record/associations/join_dependency/join_part.rb +0 -1
  10. data/lib/active_record/associations/singular_association.rb +6 -1
  11. data/lib/active_record/attribute_methods.rb +7 -4
  12. data/lib/active_record/attribute_methods/serialization.rb +8 -7
  13. data/lib/active_record/attribute_set/builder.rb +5 -2
  14. data/lib/active_record/autosave_association.rb +3 -1
  15. data/lib/active_record/callbacks.rb +5 -5
  16. data/lib/active_record/connection_adapters/abstract/connection_pool.rb +8 -6
  17. data/lib/active_record/connection_adapters/abstract/database_statements.rb +2 -1
  18. data/lib/active_record/connection_adapters/abstract/quoting.rb +1 -1
  19. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +11 -18
  20. data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +1 -1
  21. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +1 -1
  22. data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +20 -9
  23. data/lib/active_record/connection_adapters/column.rb +20 -0
  24. data/lib/active_record/connection_adapters/connection_specification.rb +8 -3
  25. data/lib/active_record/connection_adapters/mysql2_adapter.rb +0 -5
  26. data/lib/active_record/connection_adapters/mysql_adapter.rb +1 -1
  27. data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +3 -3
  28. data/lib/active_record/connection_adapters/postgresql/oid/range.rb +7 -4
  29. data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +1 -1
  30. data/lib/active_record/connection_adapters/postgresql/quoting.rb +1 -1
  31. data/lib/active_record/connection_adapters/postgresql_adapter.rb +4 -8
  32. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +0 -4
  33. data/lib/active_record/core.rb +14 -9
  34. data/lib/active_record/errors.rb +1 -1
  35. data/lib/active_record/fixtures.rb +3 -35
  36. data/lib/active_record/gem_version.rb +1 -1
  37. data/lib/active_record/inheritance.rb +2 -2
  38. data/lib/active_record/model_schema.rb +8 -11
  39. data/lib/active_record/querying.rb +12 -2
  40. data/lib/active_record/railties/databases.rake +1 -1
  41. data/lib/active_record/reflection.rb +24 -12
  42. data/lib/active_record/relation.rb +2 -3
  43. data/lib/active_record/relation/finder_methods.rb +19 -10
  44. data/lib/active_record/relation/merger.rb +15 -15
  45. data/lib/active_record/relation/predicate_builder.rb +1 -1
  46. data/lib/active_record/relation/predicate_builder/array_handler.rb +9 -4
  47. data/lib/active_record/relation/query_methods.rb +6 -3
  48. data/lib/active_record/result.rb +4 -0
  49. data/lib/active_record/schema_dumper.rb +2 -0
  50. data/lib/active_record/scoping/named.rb +4 -0
  51. data/lib/active_record/tasks/database_tasks.rb +6 -3
  52. data/lib/active_record/transactions.rb +3 -3
  53. data/lib/active_record/type/boolean.rb +12 -1
  54. data/lib/active_record/validations/associated.rb +5 -3
  55. data/lib/active_record/validations/presence.rb +5 -3
  56. metadata +16 -16
@@ -63,7 +63,7 @@ module ActiveRecord
63
63
  # records, artists => artists_records
64
64
  # music_artists, music_records => music_artists_records
65
65
  def self.derive_join_table_name(first_table, second_table) # :nodoc:
66
- [first_table.to_s, second_table.to_s].sort.join("\0").gsub(/^(.*_)(.+)\0\1(.+)/, '\1\2_\3').gsub("\0", "_")
66
+ [first_table.to_s, second_table.to_s].sort.join("\0").gsub(/^(.*_)(.+)\0\1(.+)/, '\1\2_\3').tr("\0", "_")
67
67
  end
68
68
 
69
69
  module ClassMethods
@@ -297,16 +297,13 @@ module ActiveRecord
297
297
  undefine_attribute_methods
298
298
  connection.schema_cache.clear_table_cache!(table_name) if table_exists?
299
299
 
300
- @arel_engine = nil
301
- @column_names = nil
302
- @column_types = nil
303
- @content_columns = nil
304
- @default_attributes = nil
305
- @dynamic_methods_hash = nil
306
- @inheritance_column = nil unless defined?(@explicit_inheritance_column) && @explicit_inheritance_column
307
- @relation = nil
308
- @time_zone_column_names = nil
309
- @cached_time_zone = nil
300
+ @arel_engine = nil
301
+ @column_names = nil
302
+ @column_types = nil
303
+ @content_columns = nil
304
+ @default_attributes = nil
305
+ @inheritance_column = nil unless defined?(@explicit_inheritance_column) && @explicit_inheritance_column
306
+ @relation = nil
310
307
  end
311
308
 
312
309
  private
@@ -37,8 +37,18 @@ module ActiveRecord
37
37
  # Post.find_by_sql ["SELECT body FROM comments WHERE author = :user_id OR approved_by = :user_id", { :user_id => user_id }]
38
38
  def find_by_sql(sql, binds = [])
39
39
  result_set = connection.select_all(sanitize_sql(sql), "#{name} Load", binds)
40
- column_types = result_set.column_types.except(*columns_hash.keys)
41
- result_set.map { |record| instantiate(record, column_types) }
40
+ column_types = result_set.column_types.dup
41
+ columns_hash.each_key { |k| column_types.delete k }
42
+ message_bus = ActiveSupport::Notifications.instrumenter
43
+
44
+ payload = {
45
+ record_count: result_set.length,
46
+ class_name: name
47
+ }
48
+
49
+ message_bus.instrument('instantiation.active_record', payload) do
50
+ result_set.map { |record| instantiate(record, column_types) }
51
+ end
42
52
  end
43
53
 
44
54
  # Returns the result of an SQL statement that should only include a COUNT(*) in the SELECT part.
@@ -215,7 +215,7 @@ db_namespace = namespace :db do
215
215
 
216
216
  Dir["#{base_dir}/**/*.yml"].each do |file|
217
217
  if data = YAML::load(ERB.new(IO.read(file)).result)
218
- data.keys.each do |key|
218
+ data.each_key do |key|
219
219
  key_id = ActiveRecord::FixtureSet.identify(key)
220
220
 
221
221
  if key == label || key_id == id.to_i
@@ -1,4 +1,5 @@
1
1
  require 'thread'
2
+ require 'active_support/core_ext/string/filters'
2
3
 
3
4
  module ActiveRecord
4
5
  # = Active Record Reflection
@@ -153,8 +154,11 @@ module ActiveRecord
153
154
  end
154
155
 
155
156
  def source_macro
156
- ActiveSupport::Deprecation.warn("ActiveRecord::Base.source_macro is deprecated and " \
157
- "will be removed without replacement.")
157
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
158
+ ActiveRecord::Base.source_macro is deprecated and will be removed
159
+ without replacement.
160
+ MSG
161
+
158
162
  macro
159
163
  end
160
164
  end
@@ -339,13 +343,14 @@ module ActiveRecord
339
343
  return unless scope
340
344
 
341
345
  if scope.arity > 0
342
- ActiveSupport::Deprecation.warn \
343
- "The association scope '#{name}' is instance dependent (the scope " \
344
- "block takes an argument). Preloading happens before the individual " \
345
- "instances are created. This means that there is no instance being " \
346
- "passed to the association scope. This will most likely result in " \
347
- "broken or incorrect behavior. Joining, Preloading and eager loading " \
348
- "of these associations is deprecated and will be removed in the future."
346
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
347
+ The association scope '#{name}' is instance dependent (the scope
348
+ block takes an argument). Preloading happens before the individual
349
+ instances are created. This means that there is no instance being
350
+ passed to the association scope. This will most likely result in
351
+ broken or incorrect behavior. Joining, Preloading and eager loading
352
+ of these associations is deprecated and will be removed in the future.
353
+ MSG
349
354
  end
350
355
  end
351
356
  alias :check_eager_loadable! :check_preloadable!
@@ -746,8 +751,11 @@ module ActiveRecord
746
751
 
747
752
  # The macro used by the source association
748
753
  def source_macro
749
- ActiveSupport::Deprecation.warn("ActiveRecord::Base.source_macro is deprecated and " \
750
- "will be removed without replacement.")
754
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
755
+ ActiveRecord::Base.source_macro is deprecated and will be removed
756
+ without replacement.
757
+ MSG
758
+
751
759
  source_reflection.source_macro
752
760
  end
753
761
 
@@ -821,7 +829,11 @@ module ActiveRecord
821
829
  end
822
830
 
823
831
  if through_reflection.polymorphic?
824
- raise HasManyThroughAssociationPolymorphicThroughError.new(active_record.name, self)
832
+ if has_one?
833
+ raise HasOneAssociationPolymorphicThroughError.new(active_record.name, self)
834
+ else
835
+ raise HasManyThroughAssociationPolymorphicThroughError.new(active_record.name, self)
836
+ end
825
837
  end
826
838
 
827
839
  if source_reflection.nil?
@@ -4,8 +4,6 @@ require 'arel/collectors/bind'
4
4
  module ActiveRecord
5
5
  # = Active Record Relation
6
6
  class Relation
7
- JoinOperation = Struct.new(:relation, :join_class, :on)
8
-
9
7
  MULTI_VALUE_METHODS = [:includes, :eager_load, :preload, :select, :group,
10
8
  :order, :joins, :where, :having, :bind, :references,
11
9
  :extending, :unscope]
@@ -305,7 +303,8 @@ module ActiveRecord
305
303
  # Updates all records with details given if they match a set of conditions supplied, limits and order can
306
304
  # also be supplied. This method constructs a single SQL UPDATE statement and sends it straight to the
307
305
  # database. It does not instantiate the involved models and it does not trigger Active Record callbacks
308
- # or validations.
306
+ # or validations. Values passed to `update_all` will not go through ActiveRecord's type-casting behavior.
307
+ # It should receive only values that can be passed as-is to the SQL database.
309
308
  #
310
309
  # ==== Parameters
311
310
  #
@@ -1,4 +1,5 @@
1
1
  require 'active_support/deprecation'
2
+ require 'active_support/core_ext/string/filters'
2
3
 
3
4
  module ActiveRecord
4
5
  module FinderMethods
@@ -138,7 +139,7 @@ module ActiveRecord
138
139
  # Same as +first+ but raises <tt>ActiveRecord::RecordNotFound</tt> if no record
139
140
  # is found. Note that <tt>first!</tt> accepts no arguments.
140
141
  def first!
141
- first or raise RecordNotFound.new("Couldn't find #{@klass.name} with [#{arel.where_sql}]")
142
+ find_nth! 0
142
143
  end
143
144
 
144
145
  # Find the last record (or last N records if a parameter is supplied).
@@ -187,7 +188,7 @@ module ActiveRecord
187
188
  # Same as +second+ but raises <tt>ActiveRecord::RecordNotFound</tt> if no record
188
189
  # is found.
189
190
  def second!
190
- second or raise RecordNotFound.new("Couldn't find #{@klass.name} with [#{arel.where_sql}]")
191
+ find_nth! 1
191
192
  end
192
193
 
193
194
  # Find the third record.
@@ -203,7 +204,7 @@ module ActiveRecord
203
204
  # Same as +third+ but raises <tt>ActiveRecord::RecordNotFound</tt> if no record
204
205
  # is found.
205
206
  def third!
206
- third or raise RecordNotFound.new("Couldn't find #{@klass.name} with [#{arel.where_sql}]")
207
+ find_nth! 2
207
208
  end
208
209
 
209
210
  # Find the fourth record.
@@ -219,7 +220,7 @@ module ActiveRecord
219
220
  # Same as +fourth+ but raises <tt>ActiveRecord::RecordNotFound</tt> if no record
220
221
  # is found.
221
222
  def fourth!
222
- fourth or raise RecordNotFound.new("Couldn't find #{@klass.name} with [#{arel.where_sql}]")
223
+ find_nth! 3
223
224
  end
224
225
 
225
226
  # Find the fifth record.
@@ -235,7 +236,7 @@ module ActiveRecord
235
236
  # Same as +fifth+ but raises <tt>ActiveRecord::RecordNotFound</tt> if no record
236
237
  # is found.
237
238
  def fifth!
238
- fifth or raise RecordNotFound.new("Couldn't find #{@klass.name} with [#{arel.where_sql}]")
239
+ find_nth! 4
239
240
  end
240
241
 
241
242
  # Find the forty-second record. Also known as accessing "the reddit".
@@ -251,7 +252,7 @@ module ActiveRecord
251
252
  # Same as +forty_two+ but raises <tt>ActiveRecord::RecordNotFound</tt> if no record
252
253
  # is found.
253
254
  def forty_two!
254
- forty_two or raise RecordNotFound.new("Couldn't find #{@klass.name} with [#{arel.where_sql}]")
255
+ find_nth! 41
255
256
  end
256
257
 
257
258
  # Returns +true+ if a record exists in the table that matches the +id+ or
@@ -284,8 +285,10 @@ module ActiveRecord
284
285
  def exists?(conditions = :none)
285
286
  if Base === conditions
286
287
  conditions = conditions.id
287
- ActiveSupport::Deprecation.warn "You are passing an instance of ActiveRecord::Base to `exists?`." \
288
- "Please pass the id of the object by calling `.id`"
288
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
289
+ You are passing an instance of ActiveRecord::Base to `exists?`.
290
+ Please pass the id of the object by calling `.id`
291
+ MSG
289
292
  end
290
293
 
291
294
  return false if !conditions
@@ -435,8 +438,10 @@ module ActiveRecord
435
438
  def find_one(id)
436
439
  if ActiveRecord::Base === id
437
440
  id = id.id
438
- ActiveSupport::Deprecation.warn "You are passing an instance of ActiveRecord::Base to `find`." \
439
- "Please pass the id of the object by calling `.id`"
441
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
442
+ You are passing an instance of ActiveRecord::Base to `find`.
443
+ Please pass the id of the object by calling `.id`
444
+ MSG
440
445
  end
441
446
 
442
447
  column = columns_hash[primary_key]
@@ -489,6 +494,10 @@ module ActiveRecord
489
494
  end
490
495
  end
491
496
 
497
+ def find_nth!(index)
498
+ find_nth(index, offset_index) or raise RecordNotFound.new("Couldn't find #{@klass.name} with [#{arel.where_sql}]")
499
+ end
500
+
492
501
  def find_nth_with_limit(offset, limit)
493
502
  relation = if order_values.empty? && primary_key
494
503
  order(arel_table[primary_key].asc)
@@ -13,7 +13,7 @@ module ActiveRecord
13
13
  @hash = hash
14
14
  end
15
15
 
16
- def merge
16
+ def merge #:nodoc:
17
17
  Merger.new(relation, other).merge
18
18
  end
19
19
 
@@ -83,12 +83,12 @@ module ActiveRecord
83
83
  private
84
84
 
85
85
  def merge_joins
86
- return if values[:joins].blank?
86
+ return if other.joins_values.blank?
87
87
 
88
88
  if other.klass == relation.klass
89
- relation.joins!(*values[:joins])
89
+ relation.joins!(*other.joins_values)
90
90
  else
91
- joins_dependency, rest = values[:joins].partition do |join|
91
+ joins_dependency, rest = other.joins_values.partition do |join|
92
92
  case join
93
93
  when Hash, Symbol, Array
94
94
  true
@@ -108,10 +108,10 @@ module ActiveRecord
108
108
 
109
109
  def merge_multi_values
110
110
  lhs_wheres = relation.where_values
111
- rhs_wheres = values[:where] || []
111
+ rhs_wheres = other.where_values
112
112
 
113
113
  lhs_binds = relation.bind_values
114
- rhs_binds = values[:bind] || []
114
+ rhs_binds = other.bind_values
115
115
 
116
116
  removed, kept = partition_overwrites(lhs_wheres, rhs_wheres)
117
117
 
@@ -133,23 +133,23 @@ module ActiveRecord
133
133
  relation.where_values = where_values
134
134
  relation.bind_values = bind_values
135
135
 
136
- if values[:reordering]
136
+ if other.reordering_value
137
137
  # override any order specified in the original relation
138
- relation.reorder! values[:order]
139
- elsif values[:order]
138
+ relation.reorder! other.order_values
139
+ elsif other.order_values
140
140
  # merge in order_values from relation
141
- relation.order! values[:order]
141
+ relation.order! other.order_values
142
142
  end
143
143
 
144
- relation.extend(*values[:extending]) unless values[:extending].blank?
144
+ relation.extend(*other.extending_values) unless other.extending_values.blank?
145
145
  end
146
146
 
147
147
  def merge_single_values
148
- relation.from_value = values[:from] unless relation.from_value
149
- relation.lock_value = values[:lock] unless relation.lock_value
148
+ relation.from_value = other.from_value unless relation.from_value
149
+ relation.lock_value = other.lock_value unless relation.lock_value
150
150
 
151
- unless values[:create_with].blank?
152
- relation.create_with_value = (relation.create_with_value || {}).merge(values[:create_with])
151
+ unless other.create_with_value.blank?
152
+ relation.create_with_value = (relation.create_with_value || {}).merge(other.create_with_value)
153
153
  end
154
154
  end
155
155
 
@@ -109,7 +109,7 @@ module ActiveRecord
109
109
  # FIXME: I think we need to deprecate this behavior
110
110
  register_handler(Class, ->(attribute, value) { attribute.eq(value.name) })
111
111
  register_handler(Base, ->(attribute, value) { attribute.eq(value.id) })
112
- register_handler(Range, ->(attribute, value) { attribute.in(value) })
112
+ register_handler(Range, ->(attribute, value) { attribute.between(value) })
113
113
  register_handler(Relation, RelationHandler.new)
114
114
  register_handler(Array, ArrayHandler.new)
115
115
 
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext/string/filters'
2
+
1
3
  module ActiveRecord
2
4
  class PredicateBuilder
3
5
  class ArrayHandler # :nodoc:
@@ -6,9 +8,12 @@ module ActiveRecord
6
8
  nils, values = values.partition(&:nil?)
7
9
 
8
10
  if values.any? { |val| val.is_a?(Array) }
9
- ActiveSupport::Deprecation.warn "Passing a nested array to Active Record " \
10
- "finder methods is deprecated and will be removed. Flatten your array " \
11
- "before using it for 'IN' conditions."
11
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
12
+ Passing a nested array to Active Record finder methods is
13
+ deprecated and will be removed. Flatten your array before using
14
+ it for 'IN' conditions.
15
+ MSG
16
+
12
17
  values = values.flatten
13
18
  end
14
19
 
@@ -27,7 +32,7 @@ module ActiveRecord
27
32
  values_predicate = values_predicate.or(attribute.eq(nil))
28
33
  end
29
34
 
30
- array_predicates = ranges.map { |range| attribute.in(range) }
35
+ array_predicates = ranges.map { |range| attribute.between(range) }
31
36
  array_predicates.unshift(values_predicate)
32
37
  array_predicates.inject { |composite, predicate| composite.or(predicate) }
33
38
  end
@@ -1,4 +1,5 @@
1
1
  require 'active_support/core_ext/array/wrap'
2
+ require 'active_support/core_ext/string/filters'
2
3
  require 'active_model/forbidden_attributes_protection'
3
4
 
4
5
  module ActiveRecord
@@ -94,8 +95,10 @@ module ActiveRecord
94
95
  def check_cached_relation # :nodoc:
95
96
  if defined?(@arel) && @arel
96
97
  @arel = nil
97
- ActiveSupport::Deprecation.warn "Modifying already cached Relation. The " \
98
- "cache will be reset. Use a cloned Relation to prevent this warning."
98
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
99
+ Modifying already cached Relation. The cache will be reset. Use a
100
+ cloned Relation to prevent this warning.
101
+ MSG
99
102
  end
100
103
  end
101
104
 
@@ -913,7 +916,7 @@ module ActiveRecord
913
916
 
914
917
  where_values.reject! do |rel|
915
918
  case rel
916
- when Arel::Nodes::In, Arel::Nodes::NotIn, Arel::Nodes::Equality, Arel::Nodes::NotEqual
919
+ when Arel::Nodes::Between, Arel::Nodes::In, Arel::Nodes::NotIn, Arel::Nodes::Equality, Arel::Nodes::NotEqual, Arel::Nodes::LessThanOrEqual, Arel::Nodes::GreaterThanOrEqual
917
920
  subrelation = (rel.left.kind_of?(Arel::Attributes::Attribute) ? rel.left : rel.right)
918
921
  subrelation.name == target_value
919
922
  end
@@ -42,6 +42,10 @@ module ActiveRecord
42
42
  @column_types = column_types
43
43
  end
44
44
 
45
+ def length
46
+ @rows.length
47
+ end
48
+
45
49
  def each
46
50
  if block_given?
47
51
  hash_rows.each { |row| yield row }
@@ -118,6 +118,8 @@ HEADER
118
118
  if pkcol
119
119
  if pk != 'id'
120
120
  tbl.print %Q(, primary_key: "#{pk}")
121
+ elsif pkcol.sql_type == 'bigint'
122
+ tbl.print ", id: :bigserial"
121
123
  elsif pkcol.sql_type == 'uuid'
122
124
  tbl.print ", id: :uuid"
123
125
  tbl.print %Q(, default: "#{pkcol.default_function}") if pkcol.default_function
@@ -139,6 +139,10 @@ module ActiveRecord
139
139
  # Article.published.featured.latest_article
140
140
  # Article.featured.titles
141
141
  def scope(name, body, &block)
142
+ unless body.respond_to?:call
143
+ raise ArgumentError, 'The scope body needs to be callable.'
144
+ end
145
+
142
146
  if dangerous_class_method?(name)
143
147
  raise ArgumentError, "You tried to define a scope named \"#{name}\" " \
144
148
  "on the model \"#{self.name}\", but Active Record already defined " \
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext/string/filters'
2
+
1
3
  module ActiveRecord
2
4
  module Tasks # :nodoc:
3
5
  class DatabaseAlreadyExists < StandardError; end # :nodoc:
@@ -187,9 +189,10 @@ module ActiveRecord
187
189
  end
188
190
 
189
191
  def load_schema(format = ActiveRecord::Base.schema_format, file = nil)
190
- ActiveSupport::Deprecation.warn \
191
- "This method will act on a specific connection in the future. " \
192
- "To act on the current connection, use `load_schema_current` instead."
192
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
193
+ This method will act on a specific connection in the future.
194
+ To act on the current connection, use `load_schema_current` instead.
195
+ MSG
193
196
 
194
197
  load_schema_current(format, file)
195
198
  end
@@ -11,7 +11,7 @@ module ActiveRecord
11
11
  "\n" \
12
12
  "You can opt into the new behavior and remove this warning by setting:\n" \
13
13
  "\n" \
14
- " config.active_record.raise_in_transactional_callbacks = true"
14
+ " config.active_record.raise_in_transactional_callbacks = true\n\n"
15
15
 
16
16
  included do
17
17
  define_callbacks :commit, :rollback,
@@ -309,7 +309,7 @@ module ActiveRecord
309
309
  # Ensure that it is not called if the object was never persisted (failed create),
310
310
  # but call it after the commit of a destroyed object.
311
311
  def committed!(should_run_callbacks = true) #:nodoc:
312
- run_callbacks :commit if should_run_callbacks && destroyed? || persisted?
312
+ _run_commit_callbacks if should_run_callbacks && destroyed? || persisted?
313
313
  ensure
314
314
  force_clear_transaction_record_state
315
315
  end
@@ -317,7 +317,7 @@ module ActiveRecord
317
317
  # Call the +after_rollback+ callbacks. The +force_restore_state+ argument indicates if the record
318
318
  # state should be rolled back to the beginning or just to the last savepoint.
319
319
  def rolledback!(force_restore_state = false, should_run_callbacks = true) #:nodoc:
320
- run_callbacks :rollback if should_run_callbacks
320
+ _run_rollback_callbacks if should_run_callbacks
321
321
  ensure
322
322
  restore_transaction_record_state(force_restore_state)
323
323
  clear_transaction_record_state