activerecord 6.0.1 → 6.0.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +111 -0
- data/README.rdoc +1 -1
- data/lib/active_record.rb +1 -0
- data/lib/active_record/advisory_lock_base.rb +18 -0
- data/lib/active_record/aggregations.rb +0 -1
- data/lib/active_record/association_relation.rb +4 -11
- data/lib/active_record/associations.rb +1 -1
- data/lib/active_record/associations/alias_tracker.rb +0 -1
- data/lib/active_record/associations/association.rb +5 -9
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +0 -2
- data/lib/active_record/associations/collection_association.rb +6 -2
- data/lib/active_record/associations/collection_proxy.rb +1 -2
- data/lib/active_record/associations/has_many_association.rb +0 -1
- data/lib/active_record/associations/join_dependency.rb +9 -0
- data/lib/active_record/associations/preloader.rb +1 -2
- data/lib/active_record/attribute_assignment.rb +0 -1
- data/lib/active_record/attribute_decorators.rb +0 -2
- data/lib/active_record/attribute_methods/before_type_cast.rb +0 -1
- data/lib/active_record/attribute_methods/dirty.rb +2 -2
- data/lib/active_record/attribute_methods/primary_key.rb +0 -2
- data/lib/active_record/attribute_methods/read.rb +0 -1
- data/lib/active_record/attribute_methods/serialization.rb +0 -1
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +0 -2
- data/lib/active_record/attribute_methods/write.rb +0 -1
- data/lib/active_record/attributes.rb +0 -1
- data/lib/active_record/autosave_association.rb +1 -3
- data/lib/active_record/callbacks.rb +1 -2
- data/lib/active_record/coders/yaml_column.rb +0 -1
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +0 -3
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +17 -15
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +0 -1
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +1 -2
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +27 -27
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +47 -30
- data/lib/active_record/connection_adapters/abstract/transaction.rb +4 -5
- data/lib/active_record/connection_adapters/abstract_adapter.rb +7 -3
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +12 -28
- data/lib/active_record/connection_adapters/connection_specification.rb +1 -2
- data/lib/active_record/connection_adapters/mysql/column.rb +1 -1
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +5 -11
- data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +0 -1
- data/lib/active_record/connection_adapters/mysql/schema_creation.rb +1 -2
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +8 -8
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +6 -2
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/oid.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/point.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/range.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +2 -2
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +15 -29
- data/lib/active_record/connection_adapters/postgresql/utils.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +5 -2
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +5 -6
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +0 -1
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +3 -3
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +8 -7
- data/lib/active_record/connection_adapters/statement_pool.rb +0 -1
- data/lib/active_record/connection_handling.rb +10 -26
- data/lib/active_record/core.rb +0 -2
- data/lib/active_record/counter_cache.rb +4 -1
- data/lib/active_record/database_configurations/url_config.rb +0 -1
- data/lib/active_record/dynamic_matchers.rb +2 -3
- data/lib/active_record/explain.rb +0 -1
- data/lib/active_record/fixture_set/table_row.rb +0 -1
- data/lib/active_record/fixture_set/table_rows.rb +0 -1
- data/lib/active_record/fixtures.rb +0 -3
- data/lib/active_record/gem_version.rb +1 -1
- data/lib/active_record/inheritance.rb +0 -3
- data/lib/active_record/insert_all.rb +3 -3
- data/lib/active_record/internal_metadata.rb +1 -1
- data/lib/active_record/locking/optimistic.rb +0 -1
- data/lib/active_record/log_subscriber.rb +1 -1
- data/lib/active_record/middleware/database_selector.rb +0 -1
- data/lib/active_record/middleware/database_selector/resolver.rb +1 -2
- data/lib/active_record/migration.rb +4 -4
- data/lib/active_record/migration/command_recorder.rb +6 -18
- data/lib/active_record/migration/compatibility.rb +3 -3
- data/lib/active_record/migration/join_table.rb +0 -1
- data/lib/active_record/model_schema.rb +0 -2
- data/lib/active_record/nested_attributes.rb +0 -2
- data/lib/active_record/no_touching.rb +2 -2
- data/lib/active_record/null_relation.rb +0 -1
- data/lib/active_record/persistence.rb +4 -5
- data/lib/active_record/querying.rb +1 -1
- data/lib/active_record/railtie.rb +1 -1
- data/lib/active_record/railties/collection_cache_association_loading.rb +1 -1
- data/lib/active_record/railties/databases.rake +3 -0
- data/lib/active_record/reflection.rb +8 -8
- data/lib/active_record/relation.rb +12 -1
- data/lib/active_record/relation/batches.rb +0 -1
- data/lib/active_record/relation/calculations.rb +1 -1
- data/lib/active_record/relation/delegation.rb +7 -6
- data/lib/active_record/relation/finder_methods.rb +0 -1
- data/lib/active_record/relation/from_clause.rb +4 -0
- data/lib/active_record/relation/merger.rb +0 -1
- data/lib/active_record/relation/predicate_builder.rb +1 -5
- data/lib/active_record/relation/query_methods.rb +22 -9
- data/lib/active_record/relation/spawn_methods.rb +0 -1
- data/lib/active_record/relation/where_clause.rb +0 -1
- data/lib/active_record/result.rb +0 -1
- data/lib/active_record/schema_migration.rb +1 -1
- data/lib/active_record/scoping.rb +0 -1
- data/lib/active_record/scoping/default.rb +0 -1
- data/lib/active_record/scoping/named.rb +3 -3
- data/lib/active_record/store.rb +1 -1
- data/lib/active_record/suppressor.rb +2 -2
- data/lib/active_record/table_metadata.rb +16 -1
- data/lib/active_record/tasks/mysql_database_tasks.rb +0 -1
- data/lib/active_record/tasks/postgresql_database_tasks.rb +0 -1
- data/lib/active_record/tasks/sqlite_database_tasks.rb +0 -1
- data/lib/active_record/test_fixtures.rb +2 -1
- data/lib/active_record/timestamp.rb +0 -1
- data/lib/active_record/touch_later.rb +1 -2
- data/lib/active_record/transactions.rb +8 -8
- data/lib/active_record/type.rb +0 -1
- data/lib/active_record/type/adapter_specific_registry.rb +2 -5
- data/lib/active_record/type/hash_lookup_type_map.rb +0 -1
- data/lib/active_record/type/serialized.rb +0 -1
- data/lib/active_record/type/type_map.rb +0 -1
- data/lib/active_record/type/unsigned_integer.rb +0 -1
- data/lib/active_record/validations.rb +2 -3
- data/lib/active_record/validations/associated.rb +1 -2
- data/lib/arel.rb +5 -1
- data/lib/arel/predications.rb +5 -6
- data/lib/arel/visitors/depth_first.rb +0 -1
- data/lib/arel/visitors/dot.rb +0 -1
- data/lib/arel/visitors/mssql.rb +0 -1
- data/lib/arel/visitors/oracle.rb +1 -2
- data/lib/arel/visitors/oracle12.rb +0 -1
- data/lib/arel/visitors/postgresql.rb +0 -1
- data/lib/arel/visitors/sqlite.rb +0 -1
- data/lib/arel/visitors/to_sql.rb +0 -1
- data/lib/arel/visitors/visitor.rb +0 -1
- data/lib/arel/visitors/where_sql.rb +0 -1
- data/lib/rails/generators/active_record/application_record/application_record_generator.rb +0 -1
- data/lib/rails/generators/active_record/migration.rb +0 -1
- data/lib/rails/generators/active_record/migration/templates/migration.rb.tt +1 -1
- data/lib/rails/generators/active_record/model/model_generator.rb +0 -1
- metadata +12 -11
@@ -385,6 +385,15 @@ module ActiveRecord
|
|
385
385
|
end
|
386
386
|
private :compute_cache_version
|
387
387
|
|
388
|
+
# Returns a cache key along with the version.
|
389
|
+
def cache_key_with_version
|
390
|
+
if version = cache_version
|
391
|
+
"#{cache_key}-#{version}"
|
392
|
+
else
|
393
|
+
cache_key
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
388
397
|
# Scope all queries to the current scope.
|
389
398
|
#
|
390
399
|
# Comment.where(post_id: 1).scoping do
|
@@ -479,7 +488,9 @@ module ActiveRecord
|
|
479
488
|
|
480
489
|
if touch
|
481
490
|
names = touch if touch != true
|
482
|
-
|
491
|
+
names = Array.wrap(names)
|
492
|
+
options = names.extract_options!
|
493
|
+
touch_updates = klass.touch_attributes_with_time(*names, **options)
|
483
494
|
updates.merge!(touch_updates) unless touch_updates.empty?
|
484
495
|
end
|
485
496
|
|
@@ -172,7 +172,7 @@ module ActiveRecord
|
|
172
172
|
# # SELECT people.id FROM people WHERE people.age = 21 LIMIT 5
|
173
173
|
# # => [2, 3]
|
174
174
|
#
|
175
|
-
# Person.pluck('DATEDIFF(updated_at, created_at)')
|
175
|
+
# Person.pluck(Arel.sql('DATEDIFF(updated_at, created_at)'))
|
176
176
|
# # SELECT DATEDIFF(updated_at, created_at) FROM people
|
177
177
|
# # => ['0', '27761', '173']
|
178
178
|
#
|
@@ -60,15 +60,17 @@ module ActiveRecord
|
|
60
60
|
return if method_defined?(method)
|
61
61
|
|
62
62
|
if /\A[a-zA-Z_]\w*[!?]?\z/.match?(method)
|
63
|
+
definition = RUBY_VERSION >= "2.7" ? "..." : "*args, &block"
|
63
64
|
module_eval <<-RUBY, __FILE__, __LINE__ + 1
|
64
|
-
def #{method}(
|
65
|
-
scoping { klass.#{method}(
|
65
|
+
def #{method}(#{definition})
|
66
|
+
scoping { klass.#{method}(#{definition}) }
|
66
67
|
end
|
67
68
|
RUBY
|
68
69
|
else
|
69
70
|
define_method(method) do |*args, &block|
|
70
71
|
scoping { klass.public_send(method, *args, &block) }
|
71
72
|
end
|
73
|
+
ruby2_keywords(method) if respond_to?(:ruby2_keywords, true)
|
72
74
|
end
|
73
75
|
end
|
74
76
|
end
|
@@ -99,7 +101,6 @@ module ActiveRecord
|
|
99
101
|
end
|
100
102
|
|
101
103
|
private
|
102
|
-
|
103
104
|
def method_missing(method, *args, &block)
|
104
105
|
if @klass.respond_to?(method)
|
105
106
|
@klass.generate_relation_method(method)
|
@@ -108,15 +109,15 @@ module ActiveRecord
|
|
108
109
|
super
|
109
110
|
end
|
110
111
|
end
|
112
|
+
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
|
111
113
|
end
|
112
114
|
|
113
115
|
module ClassMethods # :nodoc:
|
114
|
-
def create(klass, *args)
|
115
|
-
relation_class_for(klass).new(klass, *args)
|
116
|
+
def create(klass, *args, **kwargs)
|
117
|
+
relation_class_for(klass).new(klass, *args, **kwargs)
|
116
118
|
end
|
117
119
|
|
118
120
|
private
|
119
|
-
|
120
121
|
def relation_class_for(klass)
|
121
122
|
klass.relation_delegate_class(self)
|
122
123
|
end
|
@@ -67,7 +67,7 @@ module ActiveRecord
|
|
67
67
|
|
68
68
|
attributes.flat_map do |key, value|
|
69
69
|
if value.is_a?(Hash) && !table.has_column?(key)
|
70
|
-
associated_predicate_builder(key).expand_from_hash(value)
|
70
|
+
table.associated_predicate_builder(key).expand_from_hash(value)
|
71
71
|
elsif table.associated_with?(key)
|
72
72
|
# Find the foreign key when using queries such as:
|
73
73
|
# Post.where(author: author)
|
@@ -114,10 +114,6 @@ module ActiveRecord
|
|
114
114
|
private
|
115
115
|
attr_reader :table
|
116
116
|
|
117
|
-
def associated_predicate_builder(association_name)
|
118
|
-
self.class.new(table.associated_table(association_name))
|
119
|
-
end
|
120
|
-
|
121
117
|
def convert_dot_notation_to_hash(attributes)
|
122
118
|
dot_notation = attributes.select do |k, v|
|
123
119
|
k.include?(".") && !v.is_a?(Hash)
|
@@ -51,8 +51,16 @@ module ActiveRecord
|
|
51
51
|
if not_behaves_as_nor?(opts)
|
52
52
|
ActiveSupport::Deprecation.warn(<<~MSG.squish)
|
53
53
|
NOT conditions will no longer behave as NOR in Rails 6.1.
|
54
|
-
To continue using NOR conditions, NOT each
|
55
|
-
(`#{
|
54
|
+
To continue using NOR conditions, NOT each condition individually
|
55
|
+
(`#{
|
56
|
+
opts.flat_map { |key, value|
|
57
|
+
if value.is_a?(Hash) && value.size > 1
|
58
|
+
value.map { |k, v| ".where.not(#{key.inspect} => { #{k.inspect} => ... })" }
|
59
|
+
else
|
60
|
+
".where.not(#{key.inspect} => ...)"
|
61
|
+
end
|
62
|
+
}.join
|
63
|
+
}`).
|
56
64
|
MSG
|
57
65
|
@scope.where_clause += where_clause.invert(:nor)
|
58
66
|
else
|
@@ -64,7 +72,10 @@ module ActiveRecord
|
|
64
72
|
|
65
73
|
private
|
66
74
|
def not_behaves_as_nor?(opts)
|
67
|
-
opts.is_a?(Hash)
|
75
|
+
return false unless opts.is_a?(Hash)
|
76
|
+
|
77
|
+
opts.any? { |k, v| v.is_a?(Hash) && v.size > 1 } ||
|
78
|
+
opts.size > 1
|
68
79
|
end
|
69
80
|
end
|
70
81
|
|
@@ -157,7 +168,7 @@ module ActiveRecord
|
|
157
168
|
end
|
158
169
|
|
159
170
|
def eager_load!(*args) # :nodoc:
|
160
|
-
self.eager_load_values
|
171
|
+
self.eager_load_values |= args
|
161
172
|
self
|
162
173
|
end
|
163
174
|
|
@@ -171,7 +182,7 @@ module ActiveRecord
|
|
171
182
|
end
|
172
183
|
|
173
184
|
def preload!(*args) # :nodoc:
|
174
|
-
self.preload_values
|
185
|
+
self.preload_values |= args
|
175
186
|
self
|
176
187
|
end
|
177
188
|
|
@@ -320,7 +331,7 @@ module ActiveRecord
|
|
320
331
|
def group!(*args) # :nodoc:
|
321
332
|
args.flatten!
|
322
333
|
|
323
|
-
self.group_values
|
334
|
+
self.group_values |= args
|
324
335
|
self
|
325
336
|
end
|
326
337
|
|
@@ -488,7 +499,7 @@ module ActiveRecord
|
|
488
499
|
def joins!(*args) # :nodoc:
|
489
500
|
args.compact!
|
490
501
|
args.flatten!
|
491
|
-
self.joins_values
|
502
|
+
self.joins_values |= args
|
492
503
|
self
|
493
504
|
end
|
494
505
|
|
@@ -506,7 +517,7 @@ module ActiveRecord
|
|
506
517
|
def left_outer_joins!(*args) # :nodoc:
|
507
518
|
args.compact!
|
508
519
|
args.flatten!
|
509
|
-
self.left_outer_joins_values
|
520
|
+
self.left_outer_joins_values |= args
|
510
521
|
self
|
511
522
|
end
|
512
523
|
|
@@ -1210,7 +1221,9 @@ module ActiveRecord
|
|
1210
1221
|
end
|
1211
1222
|
|
1212
1223
|
def table_name_matches?(from)
|
1213
|
-
|
1224
|
+
table_name = Regexp.escape(table.name)
|
1225
|
+
quoted_table_name = Regexp.escape(connection.quote_table_name(table.name))
|
1226
|
+
/(?:\A|(?<!FROM)\s)(?:\b#{table_name}\b|#{quoted_table_name})(?!\.)/i.match?(from.to_s)
|
1214
1227
|
end
|
1215
1228
|
|
1216
1229
|
def reverse_sql_order(order_query)
|
data/lib/active_record/result.rb
CHANGED
@@ -95,7 +95,6 @@ module ActiveRecord
|
|
95
95
|
end
|
96
96
|
|
97
97
|
private
|
98
|
-
|
99
98
|
def raise_invalid_scope_type!(scope_type)
|
100
99
|
if !VALID_SCOPE_TYPES.include?(scope_type)
|
101
100
|
raise ArgumentError, "Invalid scope type '#{scope_type}' sent to the registry. Scope types must be included in VALID_SCOPE_TYPES"
|
@@ -31,7 +31,7 @@ module ActiveRecord
|
|
31
31
|
ActiveSupport::Deprecation.warn(<<~MSG.squish)
|
32
32
|
Class level methods will no longer inherit scoping from `#{scope._deprecated_scope_source}`
|
33
33
|
in Rails 6.1. To continue using the scoped relation, pass it into the block directly.
|
34
|
-
To instead access the full set of models, as Rails 6.1 will, use `#{name}.
|
34
|
+
To instead access the full set of models, as Rails 6.1 will, use `#{name}.default_scoped`.
|
35
35
|
MSG
|
36
36
|
end
|
37
37
|
|
@@ -53,7 +53,8 @@ module ActiveRecord
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
|
56
|
+
# Returns a scope for the model with default scopes.
|
57
|
+
def default_scoped(scope = relation)
|
57
58
|
build_default_scope(scope) || scope
|
58
59
|
end
|
59
60
|
|
@@ -204,7 +205,6 @@ module ActiveRecord
|
|
204
205
|
end
|
205
206
|
|
206
207
|
private
|
207
|
-
|
208
208
|
def valid_scope_name?(name)
|
209
209
|
if respond_to?(name, true) && logger
|
210
210
|
logger.warn "Creating scope :#{name}. " \
|
data/lib/active_record/store.rb
CHANGED
@@ -103,7 +103,7 @@ module ActiveRecord
|
|
103
103
|
module ClassMethods
|
104
104
|
def store(store_attribute, options = {})
|
105
105
|
serialize store_attribute, IndifferentCoder.new(store_attribute, options[:coder])
|
106
|
-
store_accessor(store_attribute, options[:accessors], options.slice(:prefix, :suffix)) if options.has_key? :accessors
|
106
|
+
store_accessor(store_attribute, options[:accessors], **options.slice(:prefix, :suffix)) if options.has_key? :accessors
|
107
107
|
end
|
108
108
|
|
109
109
|
def store_accessor(store_attribute, *keys, prefix: nil, suffix: nil)
|
@@ -40,11 +40,11 @@ module ActiveRecord
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
def save(
|
43
|
+
def save(*, **) # :nodoc:
|
44
44
|
SuppressorRegistry.suppressed[self.class.name] ? true : super
|
45
45
|
end
|
46
46
|
|
47
|
-
def save!(
|
47
|
+
def save!(*, **) # :nodoc:
|
48
48
|
SuppressorRegistry.suppressed[self.class.name] ? true : super
|
49
49
|
end
|
50
50
|
end
|
@@ -45,7 +45,7 @@ module ActiveRecord
|
|
45
45
|
association = klass._reflect_on_association(table_name) || klass._reflect_on_association(table_name.to_s.singularize)
|
46
46
|
|
47
47
|
if !association && table_name == arel_table.name
|
48
|
-
|
48
|
+
self
|
49
49
|
elsif association && !association.polymorphic?
|
50
50
|
association_klass = association.klass
|
51
51
|
arel_table = association_klass.arel_table.alias(table_name)
|
@@ -57,6 +57,10 @@ module ActiveRecord
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
+
def associated_predicate_builder(table_name)
|
61
|
+
associated_table(table_name).predicate_builder
|
62
|
+
end
|
63
|
+
|
60
64
|
def polymorphic_association?
|
61
65
|
association && association.polymorphic?
|
62
66
|
end
|
@@ -69,6 +73,17 @@ module ActiveRecord
|
|
69
73
|
klass.reflect_on_aggregation(aggregation_name)
|
70
74
|
end
|
71
75
|
|
76
|
+
protected
|
77
|
+
def predicate_builder
|
78
|
+
if klass
|
79
|
+
predicate_builder = klass.predicate_builder.dup
|
80
|
+
predicate_builder.instance_variable_set(:@table, self)
|
81
|
+
predicate_builder
|
82
|
+
else
|
83
|
+
PredicateBuilder.new(self)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
72
87
|
private
|
73
88
|
attr_reader :klass, :types, :arel_table, :association
|
74
89
|
end
|
@@ -129,6 +129,7 @@ module ActiveRecord
|
|
129
129
|
# When connections are established in the future, begin a transaction too
|
130
130
|
@connection_subscriber = ActiveSupport::Notifications.subscribe("!connection.active_record") do |_, _, _, _, payload|
|
131
131
|
spec_name = payload[:spec_name] if payload.key?(:spec_name)
|
132
|
+
setup_shared_connection_pool
|
132
133
|
|
133
134
|
if spec_name
|
134
135
|
begin
|
@@ -179,7 +180,6 @@ module ActiveRecord
|
|
179
180
|
end
|
180
181
|
|
181
182
|
private
|
182
|
-
|
183
183
|
# Shares the writing connection pool with connections on
|
184
184
|
# other handlers.
|
185
185
|
#
|
@@ -194,6 +194,7 @@ module ActiveRecord
|
|
194
194
|
handler.connection_pool_list.each do |pool|
|
195
195
|
name = pool.spec.name
|
196
196
|
writing_connection = writing_handler.retrieve_connection_pool(name)
|
197
|
+
return unless writing_connection
|
197
198
|
handler.send(:owner_to_pool)[name] = writing_connection
|
198
199
|
end
|
199
200
|
end
|
@@ -9,7 +9,7 @@ module ActiveRecord
|
|
9
9
|
before_commit_without_transaction_enrollment :touch_deferred_attributes
|
10
10
|
end
|
11
11
|
|
12
|
-
def touch_later(*names) # :nodoc:
|
12
|
+
def touch_later(*names, **) # :nodoc:
|
13
13
|
unless persisted?
|
14
14
|
raise ActiveRecordError, <<-MSG.squish
|
15
15
|
cannot touch on a new or destroyed record object. Consider using
|
@@ -41,7 +41,6 @@ module ActiveRecord
|
|
41
41
|
end
|
42
42
|
|
43
43
|
private
|
44
|
-
|
45
44
|
def surreptitiously_touch(attrs)
|
46
45
|
attrs.each { |attr| write_attribute attr, @_touch_time }
|
47
46
|
clear_attribute_changes attrs
|
@@ -208,8 +208,8 @@ module ActiveRecord
|
|
208
208
|
# Note that "TRUNCATE" is also a MySQL DDL statement!
|
209
209
|
module ClassMethods
|
210
210
|
# See the ConnectionAdapters::DatabaseStatements#transaction API docs.
|
211
|
-
def transaction(options
|
212
|
-
connection.transaction(options, &block)
|
211
|
+
def transaction(**options, &block)
|
212
|
+
connection.transaction(**options, &block)
|
213
213
|
end
|
214
214
|
|
215
215
|
def before_commit(*args, &block) # :nodoc:
|
@@ -282,7 +282,6 @@ module ActiveRecord
|
|
282
282
|
end
|
283
283
|
|
284
284
|
private
|
285
|
-
|
286
285
|
def set_options_for_callbacks!(args, enforced_options = {})
|
287
286
|
options = args.extract_options!.merge!(enforced_options)
|
288
287
|
args << options
|
@@ -304,22 +303,22 @@ module ActiveRecord
|
|
304
303
|
|
305
304
|
# See ActiveRecord::Transactions::ClassMethods for detailed documentation.
|
306
305
|
def transaction(options = {}, &block)
|
307
|
-
self.class.transaction(options, &block)
|
306
|
+
self.class.transaction(**options, &block)
|
308
307
|
end
|
309
308
|
|
310
309
|
def destroy #:nodoc:
|
311
310
|
with_transaction_returning_status { super }
|
312
311
|
end
|
313
312
|
|
314
|
-
def save(
|
313
|
+
def save(*, **) #:nodoc:
|
315
314
|
with_transaction_returning_status { super }
|
316
315
|
end
|
317
316
|
|
318
|
-
def save!(
|
317
|
+
def save!(*, **) #:nodoc:
|
319
318
|
with_transaction_returning_status { super }
|
320
319
|
end
|
321
320
|
|
322
|
-
def touch(
|
321
|
+
def touch(*, **) #:nodoc:
|
323
322
|
with_transaction_returning_status { super }
|
324
323
|
end
|
325
324
|
|
@@ -340,7 +339,7 @@ module ActiveRecord
|
|
340
339
|
_run_commit_callbacks
|
341
340
|
end
|
342
341
|
ensure
|
343
|
-
@_committed_already_called = false
|
342
|
+
@_committed_already_called = @_trigger_update_callback = @_trigger_destroy_callback = false
|
344
343
|
end
|
345
344
|
|
346
345
|
# Call the #after_rollback callbacks. The +force_restore_state+ argument indicates if the record
|
@@ -353,6 +352,7 @@ module ActiveRecord
|
|
353
352
|
ensure
|
354
353
|
restore_transaction_record_state(force_restore_state)
|
355
354
|
clear_transaction_record_state
|
355
|
+
@_trigger_update_callback = @_trigger_destroy_callback = false if force_restore_state
|
356
356
|
end
|
357
357
|
|
358
358
|
# Executes +method+ within a transaction and captures its return value as a
|